Пример #1
0
 public override void Application_Starting()
 {
     ContainerAdapter.RegisterType <IUserService, UserService>();
     TaskManager
     .Include <ConfigTask>()
     .Include <ResourceTask>();
 }
Пример #2
0
        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();
        }
Пример #3
0
 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;
        }
Пример #5
0
        public WorkContextImplementation(ContainerAdapter containerAdapter)
        {
            _containerAdapter          = containerAdapter;
            _workContextStateProviders = containerAdapter.GetServices <IWorkContextStateProvider>();

            //Settings = Resolve<Settings>();
        }
Пример #6
0
        public override void Application_Starting()
        {
            ContainerAdapter.RegisterType <IApplicationContext, ApplicationContext>();

            TaskManager
            .Include <ConfigTask>()
            .Include <ResourceTask>();
        }
Пример #7
0
        /// <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());
        }
Пример #8
0
        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);
        }
Пример #9
0
        public void ChainContainers()
        {
            ICalcService service = new CalculatorService();

            container.AddService(typeof(ICalcService), service);

            IContainerAdapter adapter = new ContainerAdapter(container);

            Assert.AreSame(service, container.GetService(typeof(ICalcService)));
        }
Пример #10
0
 public NavigationManager(
     ContainerAdapter container,
     UrlHelper urlHelper,
     WorkContext workContext
     )
 {
     this.navigationProviders = container.GetServices <INavigationProvider>();
     this.urlHelper           = urlHelper;
     this.workContext         = workContext;
 }
Пример #11
0
        /// <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);
        }
Пример #12
0
        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);
        }
Пример #13
0
        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()));
        }
Пример #14
0
        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);
        }
Пример #15
0
 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);
         }
     }
 }
Пример #16
0
        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);
        }
Пример #17
0
        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)));
        }
Пример #18
0
        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();
        }
Пример #19
0
        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));
            }
        }
Пример #20
0
        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;
        }
Пример #22
0
        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);
        }
Пример #23
0
        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;
 }
Пример #25
0
        /// <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;
 }
Пример #28
0
 /// <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)
 {
 }
Пример #30
0
 /// <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)
 {
 }
Пример #32
0
 public FilterRegistryTestDouble(ContainerAdapter container) : base(container)
 {
 }
Пример #33
0
 public ZoneManager(ContainerAdapter container)
 {
     _zoneManagerEventHandler = container.GetServices <IZoneManagerEvents>();
 }
Пример #34
0
        /// <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;
        }
Пример #35
0
 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)
 {
 }
Пример #39
0
 public ConfigureRoutes(ContainerAdapter container, RouteCollection routes)
     : base(routes)
 {
     Invariant.IsNotNull(container, "container");
     Container = container;
 }