안녕하세요. 화합 차단을 사용하려고합니다. (화합 컨테이너를 사용하고 싶지 않습니다.) 런타임에서 구성 할 수는 있지만 구성에서 구성하는 방법을 모릅니다.컨테이너를 사용하지 않고 구성에서 유니티 가로 채기
내 코드 :
public interface ICalculator
{
int Add(int first, int second);
int Multiply(int first, int second);
}
동작 :
internal class LogBehavior : IInterceptionBehavior
{
public IMethodReturn Invoke(IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)
{
// My Code
IMethodReturn result = getNext()(input, getNext);
return result;
}
public IEnumerable<Type> GetRequiredInterfaces()
{
return Type.EmptyTypes;
}
public bool WillExecute {
get { return true; }
}
}
그리고 이것은 내가이가 작동
public static void Main(string[] args)
{
var calculator = new Calculator();
var calculatorProxy = Intercept.ThroughProxy<ICalculator>(calculator,
new InterfaceInterceptor(), new[] { new LogBehavior() });
Console.WriteLine(calculatorProxy.Add(2, 2));
Console.ReadKey();
}
를 호출하고 방법이다. 구성 파일에서이 파일을 구성해야합니다. 도와주세요
해당 URL에 무엇을하려 했습니까 : http://msdn.microsoft.com/en-us /library/ff660932%28v=PandP.20%29.aspx – samy