public void Setup() { var winsorContainer = new WindsorContainer(); AspectsConfigurator .UseContainer(new WindsorAspectsContainer(winsorContainer)) .Initialize(); winsorContainer.Register( Component .For <IServiceForBenchmark>() .ImplementedBy <ServiceForBenchmark>()); _windsorService = winsorContainer.Resolve <IServiceForBenchmark>(); _reflectedMethodService = new ServiceForBenchmark(); _reflectedMethod = typeof(IServiceForBenchmark).GetMethod(nameof(IServiceForBenchmark.Identity)); var weaver = AspectWeaverFactory.Create(); _weavedService = (IServiceForBenchmark)weaver.Weave( new ServiceForBenchmark(), typeof(IServiceForBenchmark), typeof(ServiceForBenchmark)); _proxiedService = (IServiceForBenchmark)BypassProxy <IServiceForBenchmark> .Create( new ServiceForBenchmark()); }
/// <summary> /// Выполняет привязку аспектов к сервисам. /// Важно: вызов данного метода должен распологаться после регистрации /// всех зависимостей. /// </summary> /// <param name="serviceCollection">Коллекция сервисов.</param> /// <returns>Коллекция сервисов.</returns> public static IServiceCollection UseAspectsWeaving( this IServiceCollection serviceCollection) { AspectsConfigurator .UseContainer(new MicrosoftAspectContainer(serviceCollection)) .Initialize(); return(serviceCollection); }
private static Container CreateContainer() { var container = new Container(); AspectsConfigurator .UseContainer(new SimpleInjectorAspectContainer(container)) .Initialize(); container.Register <ICustomerService, CustomerService>(); return(container); }
/// <summary> /// Выполняет привязку аспектов к сервисам. /// Важно: вызов данного метода должен распологаться после регистрации /// всех зависимостей. /// </summary> /// <param name="serviceCollection">Коллекция сервисов.</param> /// <param name="configuration">Конфигурация.</param> /// <returns>Коллекция сервисов.</returns> public static IServiceCollection UseAspectsWeaving( this IServiceCollection serviceCollection, Action <AspectsConfiguration> configuration) { if (configuration == null) { throw new ArgumentNullException(nameof(configuration)); } AspectsConfigurator .UseContainer(new MicrosoftAspectContainer(serviceCollection)) .Initialize(configuration); return(serviceCollection); }
private static WindsorContainer CreateContainer() { var container = new WindsorContainer(); AspectsConfigurator .UseContainer(new WindsorAspectsContainer(container)) .Initialize(); container.Register( Component.For <IWebPageService>() .ImplementedBy <WebPageService>()); return(container); }
private static Container CreateContainer() { var container = new Container(); AspectsConfigurator .UseContainer(new SimpleInjectorAspectContainer(container)) .Initialize(cfg => { cfg.UseClassAspectSelection(); }); container.Register <IDataService, DataService>(); return(container); }
private void InitializeSimpleInjector(IEnumerable <DependencyPair> dependency) { AspectsConfigurator .UseContainer(new SimpleInjectorAspectContainer(_simpleInjectorContainer)) .Initialize(s => { if (_configurator != null) { _configurator(s); } }); _simpleInjectorContainer.Register <TService, TImplementation>(); foreach (var pair in dependency) { _simpleInjectorContainer.Register(pair.ServiceType, pair.ImplementationType); } }
private void InitializeWindsor(IEnumerable <DependencyPair> dependency) { AspectsConfigurator .UseContainer(new WindsorAspectsContainer(_windsorContainer)) .Initialize(s => { if (_configurator != null) { _configurator(s); } }); _windsorContainer.Register( Component .For <TService>() .ImplementedBy <TImplementation>()); foreach (var pair in dependency) { _windsorContainer.Register(Component.For(pair.ServiceType).ImplementedBy(pair.ImplementationType)); } }