Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Program
- {
- public static void Main(string[] args)
- {
- using (var container = new UnityContainer())
- {
- container.AddNewExtension<Interception>();
- container.RegisterType<SimpleType>(
- new TransientLifetimeManager(),
- new Interceptor<VirtualMethodInterceptor>(),
- new InterceptionBehavior<SimpleInterceptor>());
- while (true)
- {
- try
- {
- Console.ReadKey(true);
- var type = container.Resolve<SimpleType>();
- container.Teardown(type);
- Console.WriteLine("Take a snapshot...");
- }
- catch (Exception ex)
- {
- Console.WriteLine(ex.Message);
- }
- }
- }
- }
- public class SimpleType
- {
- }
- public class SimpleInterceptor : IInterceptionBehavior
- {
- public bool WillExecute
- {
- get
- {
- return true;
- }
- }
- public IMethodReturn Invoke(IMethodInvocation input, GetNextInterceptionBehaviorDelegate getNext)
- {
- return getNext().Invoke(input, getNext);
- }
- public IEnumerable<Type> GetRequiredInterfaces()
- {
- return Type.EmptyTypes;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement