public override void Application_Starting() { ContainerAdapter.RegisterType <IUserService, UserService>(); TaskManager .Include <ConfigTask>() .Include <ResourceTask>(); }
public override void Application_Starting() { ViewEngines.Engines.Clear(); ViewEngines.Engines.Add(new PlugViewEngine()); ModelBinders.Binders.Add(typeof(WidgetBase), new WidgetBinder()); var routes = new List <RouteDescriptor>(); Type plugBaseType = typeof(PluginBase); BuildManager.GetReferencedAssemblies().Cast <Assembly>().Each(m => m.GetTypes().Each(p => { if (plugBaseType.IsAssignableFrom(p) && !p.IsAbstract && !p.IsInterface) { var plug = Activator.CreateInstance(p) as PluginBase; if (plug != null) { routes.AddRange(plug.RegistRoute()); plug.InitScript(); plug.InitStyle(); } } })); RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.OrderByDescending(m => m.Priority).Each(m => RouteTable.Routes.MapRoute(m.RouteName, m.Url, m.Defaults, m.Constraints, m.Namespaces)); ContainerAdapter.RegisterType <IUserService, UserService>(); ContainerAdapter.RegisterType <IDataDictionaryService, DataDictionaryService>(); ContainerAdapter.RegisterType <ILanguageService, LanguageService>(); DisplayViewSupport.SupportMobileView(); DisplayViewSupport.SupportIEView(); }
public void RegisterItem(ContainerAdapter c, Tuple <Item, object> i) { container.Add(c); identifier.Add(i.Item2); amount.Add(i.Item1.stack); amountTook.Add(0); }
public ContainerAdapter BuildNewAdapter(Container container) { container.Options.DefaultScopedLifestyle = new LifetimeScopeLifestyle(); var currentAssembly = new[] {typeof(Helpers.CompositionRoot).Assembly}; var concreteTypes = currentAssembly .GetImplementations( ImplementationConvention.NameEndsWith, new[] {"Repository"} ).ToList(); var containerAdapter = new ContainerAdapter(container); containerAdapter.RegisterAbstractor( settings => { settings.ApplicationAssemblies = currentAssembly; settings.ApplicationTypes = concreteTypes; }); container.Register<ILogger, FakeLogger>(Lifestyle.Singleton); return containerAdapter; }
public WorkContextImplementation(ContainerAdapter containerAdapter) { _containerAdapter = containerAdapter; _workContextStateProviders = containerAdapter.GetServices <IWorkContextStateProvider>(); //Settings = Resolve<Settings>(); }
public override void Application_Starting() { ContainerAdapter.RegisterType <IApplicationContext, ApplicationContext>(); TaskManager .Include <ConfigTask>() .Include <ResourceTask>(); }
/// <summary> /// Initializes a new instance of the <see cref="RegisterModelMetadata"/> class. /// </summary> /// <param name="container">The container.</param> public SweepGenerator(ContainerAdapter container) { Invariant.IsNotNull(container, "container"); Container = container; _timer = new Timer(); _timer.Elapsed += Elapsed; Interval = TimeSpan.FromMinutes(1); _logger = container.GetService <ILoggerFactory>().CreateLogger(GetType()); }
public HttpListenerHost(IApplicationHost applicationHost, ILogManager logManager, string serviceName, string handlerPath, string defaultRedirectPath, params Assembly[] assembliesWithServices) : base(serviceName, assembliesWithServices) { DefaultRedirectPath = defaultRedirectPath; HandlerPath = handlerPath; _logger = logManager.GetLogger("HttpServer"); _containerAdapter = new ContainerAdapter(applicationHost); }
public void ChainContainers() { ICalcService service = new CalculatorService(); container.AddService(typeof(ICalcService), service); IContainerAdapter adapter = new ContainerAdapter(container); Assert.AreSame(service, container.GetService(typeof(ICalcService))); }
public NavigationManager( ContainerAdapter container, UrlHelper urlHelper, WorkContext workContext ) { this.navigationProviders = container.GetServices <INavigationProvider>(); this.urlHelper = urlHelper; this.workContext = workContext; }
/// <summary> /// Use a custom dependency injection container implementing the Microsoft.Extensions.DependencyInjection model. /// The container lifetime will be managed by NServiceBus. /// </summary> /// <param name="configuration">The endpoint configuration.</param> /// <param name="serviceProviderFactory">The <see cref="IServiceProviderFactory{TContainerBuilder}"/> of the container to be used.</param> public static ContainerSettings <TContainerBuilder> UseContainer <TContainerBuilder>(this EndpointConfiguration configuration, IServiceProviderFactory <TContainerBuilder> serviceProviderFactory) { Guard.AgainstNull(nameof(configuration), configuration); Guard.AgainstNull(nameof(serviceProviderFactory), serviceProviderFactory); var containerSettings = new ContainerSettings <TContainerBuilder>(); IContainer containerAdapter = new ContainerAdapter <TContainerBuilder>(serviceProviderFactory, containerSettings); configuration.UseContainer(containerAdapter); return(containerSettings); }
public void GetExistingServiceFromKernel() { WindsorContainer windsor = new WindsorContainer(); windsor.AddComponent("calculator", typeof(ICalcService), typeof(CalculatorService)); IContainerAdapter adapter = new ContainerAdapter(windsor); ICalcService service = (ICalcService)adapter.GetService(typeof(ICalcService)); Assert.IsNotNull(service); }
public override void Application_Starting() { ContainerAdapter.RegisterType <IApplicationContext, ApplicationContext>(); TaskManager .Include <ConfigTask>() .Include <ResourceTask>(); Type WebPageType = typeof(WebPageBase); PrecompliedViewEngine.Regist(BuildManager.GetReferencedAssemblies().Cast <Assembly>().SelectMany(assembly => assembly.GetTypes())); }
public DeployerServiceHost(Uri baseAddress, ILifetimeScope lifetimeScope) { _host = new ServiceHost(typeof(DeployerService), baseAddress); var binding = new WSHttpBinding { Security = { Mode = SecurityMode.None } }; var endpoint = _host.AddServiceEndpoint(typeof(IDeployerService), binding, typeof(IDeployerService).Name); var container = new ContainerAdapter(lifetimeScope); _host.AddDependencyInjectionBehavior <IDeployerService>(container); TraceHelper.TraceInformation(TraceSwitches.TfsDeployer, "DeployerService will listen at {0}", endpoint.ListenUri); }
public void RegisterContainer(ContainerAdapter container) { foreach (var item in container.EnumerateItems()) { if (!item.Item1.IsAir) { if (!catalogs.ContainsKey(item.Item1.type)) { catalogs.Add(item.Item1.type, new ItemCatalog()); } catalogs[item.Item1.type].RegisterItem(container, item); } } }
public HttpListenerHost(IApplicationHost applicationHost, ILogManager logManager, IServerConfigurationManager config, string serviceName, string defaultRedirectPath, INetworkManager networkManager, params Assembly[] assembliesWithServices) : base(serviceName, assembliesWithServices) { DefaultRedirectPath = defaultRedirectPath; _networkManager = networkManager; _config = config; _logger = logManager.GetLogger("HttpServer"); _containerAdapter = new ContainerAdapter(applicationHost); }
public void RemovePromotedServiceInstance() { ContainerAdapter child = new ContainerAdapter(); container.Add(child); ICalcService service = new CalculatorService(); child.AddService(typeof(ICalcService), service, true); Assert.IsNotNull(child.GetService(typeof(ICalcService))); child.RemoveService(typeof(ICalcService), true); Assert.IsNull(child.GetService(typeof(ICalcService))); Assert.IsNull(container.GetService(typeof(ICalcService))); }
public override void Application_Starting() { ModelBinders.Binders.Add(typeof(WidgetBase), new WidgetBinder()); var routes = new List <RouteDescriptor>(); Type plugBaseType = typeof(PluginBase); Type widgetModelType = typeof(WidgetBase); var types = BuildManager.GetReferencedAssemblies().Cast <Assembly>().SelectMany(assembly => assembly.GetTypes()).ToArray(); types.Each(p => { if (plugBaseType.IsAssignableFrom(p) && !p.IsAbstract && !p.IsInterface) { var plug = Activator.CreateInstance(p) as PluginBase; if (plug != null) { var moduleRoutes = plug.RegistRoute(); if (moduleRoutes != null) { var routeArray = moduleRoutes.ToArray(); if (routeArray.Length > 0) { routes.AddRange(routeArray); } } plug.Excute(); } } else if (widgetModelType.IsAssignableFrom(p) && !p.IsAbstract && !p.IsInterface && !WidgetBase.KnownWidgetModel.ContainsKey(p.FullName)) { lock (WidgetBase.KnownWidgetModel) { WidgetBase.KnownWidgetModel.Add(p.FullName, p); } } }); PrecompliedViewEngine.Regist(types); RouteTable.Routes.IgnoreRoute("{resource}.axd/{*pathInfo}"); routes.OrderByDescending(m => m.Priority).Each(m => RouteTable.Routes.MapRoute(m.RouteName, m.Url, m.Defaults, m.Constraints, m.Namespaces)); ContainerAdapter.RegisterType <IUserService, UserService>(); ContainerAdapter.RegisterType <IDataDictionaryService, DataDictionaryService>(); ContainerAdapter.RegisterType <ILanguageService, LanguageService>(); ContainerAdapter.RegisterType <IAuthorizer, DefaultAuthorizer>(); ContainerAdapter.RegisterType <IApplicationContext, CMSApplicationContext>(DependencyLifeTime.PerRequest); //DisplayViewSupport.SupportMobileView(); //DisplayViewSupport.SupportIEView(); }
public HttpListenerHost(IApplicationHost applicationHost, ILogManager logManager, string serviceName, string handlerPath, string defaultRedirectPath, params Assembly[] assembliesWithServices) : base(serviceName, assembliesWithServices) { DefaultRedirectPath = defaultRedirectPath; ServerName = serviceName; HandlerPath = handlerPath; _logger = logManager.GetLogger("HttpServer"); _containerAdapter = new ContainerAdapter(applicationHost); for (var i = 0; i < 2; i++) { _autoResetEvents.Add(new AutoResetEvent(false)); } }
public void Items_PassCollectionInElements_ReturnsEquivalentCollection() { //Arrange var list = new List <int>() { 1, 2, 3, 4 }; var mock = new Mock <IElements <int> >(); mock.Setup(p => p.GetElements()).Returns(list); //Act var adapter = new ContainerAdapter <int>(mock.Object); //Assert CollectionAssert.AreEquivalent(list, adapter.Items); }
public static Container GetContainer() { // Double-checked locking pattern // ReSharper disable once InvertIf if (_container == null) { lock (Lock) { if (_container != null) return _container; _container = new Container(); _container.Options.DefaultScopedLifestyle = new LifetimeScopeLifestyle(); var currentAssembly = new[] {typeof (CompositionRoot).Assembly}; var concreteTypes = currentAssembly .GetImplementations( ImplementationConvention.NameEndsWith, new[] {"Repository"} ).ToList(); var containerAdapter = new ContainerAdapter(_container); containerAdapter.RegisterAbstractor( cs => { cs.ApplicationAssemblies = currentAssembly; cs.ApplicationTypes = concreteTypes; }); containerAdapter.RegisterSingleton<IUnitOfWork, FakeUnitOfWork>(); containerAdapter.RegisterSingleton<IStopwatch, FakeStopwatch>(); containerAdapter.RegisterScoped<ILogger, FakeLogger>(); _container.Verify(); } } return _container; }
public void Count_PassCollectionInElements_ReturnsProperCount() { //Arrange var list = new List <int>() { 1, 2, 3, 4 }; var expectedCount = list.Count; var mock = new Mock <IElements <int> >(); mock.Setup(p => p.GetElements()).Returns(list); //Act var adapter = new ContainerAdapter <int>(mock.Object); //Assert Assert.AreEqual(expectedCount, adapter.Count); }
public void AddPromotedServiceCreatorCallback() { ContainerAdapter child = new ContainerAdapter(); container.Add(child); ServiceCreatorCallback callback = new ServiceCreatorCallback(CreateCalculatorService); child.AddService(typeof(ICalcService), callback, true); ICalcService service = (ICalcService)child.GetService(typeof(ICalcService)); Assert.IsNotNull(service); ICalcService promotedService = (ICalcService)container.GetService(typeof(ICalcService)); Assert.IsNotNull(service); Assert.AreSame(service, promotedService); container.Remove(child); Assert.IsNull(child.GetService(typeof(ICalcService))); Assert.AreSame(container.GetService(typeof(ICalcService)), service); }
/// <summary> /// Initializes a new instance of the <see cref="WindsorControllerFactory"/> class. /// </summary> /// <param name="container"></param> public WindsorControllerFactory(ContainerAdapter container) { this.container = container; }
/// <summary> /// Initializes a new instance of the <see cref="RegisterFilterProviders"/> class. /// </summary> /// <param name="container">The container.</param> public RegisterGlobalFilterProviders(ContainerAdapter container) { Invariant.IsNotNull(container, "container"); Container = container; }
public ConfigureCallInterceptors(ICallInterceptorRegistry registry, ContainerAdapter container) : base(registry) { Invariant.IsNotNull(container, "container"); Container = container; }
protected CallInterceptorRegistry(ContainerAdapter container) { Container = container; }
/// <summary> /// /// </summary> /// <param name="container"></param> ///// <param name="filterProviders"></param> public GlobalFilterResolvingAsyncActionInvoker(ContainerAdapter container) : base(container) { _globalFilterProviders = container.GetServices <IGlobalFilterProvider>(); }
public ExtendedControllerFactoryTestDouble(ContainerAdapter container, IActionInvokerRegistry actionInvokerRegistry) : base(container, actionInvokerRegistry) { }
/// <summary> /// Initializes a new instance of the <see cref="T:MvcExtensions.RegisterFilters"/> class. /// </summary> /// <param name="container">The container.</param> public RegistrationTask(ContainerAdapter container) { Invariant.IsNotNull(container, "container"); Container = container; }
public UnityCallInterceptorRegistry(ContainerAdapter container) : base(container) { }
public FilterRegistryTestDouble(ContainerAdapter container) : base(container) { }
public ZoneManager(ContainerAdapter container) { _zoneManagerEventHandler = container.GetServices <IZoneManagerEvents>(); }
/// <summary> /// Initializes a new instance of the <see cref="ConfigureAssets"/> class. /// </summary> /// <param name="container">The container.</param> public ConfigureAssets(ContainerAdapter container) { Invariant.IsNotNull(container, "container"); Container = container; }
public FilterRegistryTestDouble(ContainerAdapter container) : base(container) { }
/// <summary> /// Initializes a new instance of the <see cref="RegisterAreaControllers"/> class. /// </summary> /// <param name="container">The container.</param> public RegisterAreaControllers(ContainerAdapter container) { Invariant.IsNotNull(container, "container"); Container = container; }
/// <summary> /// /// </summary> /// <param name="container"></param> public AreaControllerFactory(ContainerAdapter container) { this.Container = container; }
/// <summary> /// Initializes a new instance of the <see cref="USOControllerActivator"/> class. /// </summary> /// <param name="container">The container.</param> /// <param name="controllerActivatorRegistry">The controller activator registry.</param> /// <param name="actionInvokerRegistry">The action invoker registry.</param> public USOControllerActivator(ContainerAdapter container, TypeMappingRegistry <Controller, IControllerActivator> controllerActivatorRegistry, TypeMappingRegistry <Controller, IActionInvoker> actionInvokerRegistry) : base(container, controllerActivatorRegistry, actionInvokerRegistry) { }
public ConfigureRoutes(ContainerAdapter container, RouteCollection routes) : base(routes) { Invariant.IsNotNull(container, "container"); Container = container; }