Hi I am trying to use unity interception (I don't want to use unity container). I am able to configure run time but don't know how to configure it from config.
my code:
public interface ICalculator
{
int Add(int first, int second);
int Multiply(int first, int second);
}
Behavior:
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; }
}
}
And this is how I am calling it
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();
}
This is working. I need to configure this from config file. Please help