public IEnumerable <IInterceptor> DetermineInterceptors(Type pluginType, Instance instance) { if (pluginType == typeof(IMyClass)) { // DecoratorInterceptor is the simple case of wrapping one type with another // concrete type that takes the first as a dependency yield return(new FuncInterceptor <IMyClass>(i => (IMyClass) DynamicProxyHelper.CreateInterfaceProxyWithTargetInterface(typeof(IMyClass), i))); } }
static void Main(string[] args) { var container = new Container(_ => { _.For <IMyClass>() .DecorateAllWith( instance => (IMyClass) DynamicProxyHelper.CreateInterfaceProxyWithTargetInterface(typeof(IMyClass), instance)); _.For <IMyClass>().Use <MyClass>(); }); Read(); }
public static void BootstrapStructureMap() { ObjectFactory.Initialize(initializer => { initializer.AddRegistry <CommonsRegistry>(); initializer. For <IServiceOne>(). Use <ServiceOne>(). EnrichWith(s => DynamicProxyHelper.CreateInterfaceProxyWithTargetInterface(typeof(IServiceOne), s)); initializer. For <IServiceTwo>(). Use <ServiceTwo>(). EnrichWith(s => DynamicProxyHelper.CreateInterfaceProxyWithTargetInterface(typeof(IServiceTwo), s)); }); }