当前位置: 首页>>代码示例>>C#>>正文


C# IContainer.GetAllInstances方法代码示例

本文整理汇总了C#中IContainer.GetAllInstances方法的典型用法代码示例。如果您正苦于以下问题:C# IContainer.GetAllInstances方法的具体用法?C# IContainer.GetAllInstances怎么用?C# IContainer.GetAllInstances使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在IContainer的用法示例。


在下文中一共展示了IContainer.GetAllInstances方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: InitializeStartupRunners

        private static void InitializeStartupRunners(IContainer existingContainer)
        {
            var mappingDefinitions = existingContainer.GetAllInstances<IRunAtStartup>().ToList();
            mappingDefinitions.ForEach(mappingDefinition => mappingDefinition.Init());

            Mapper.AssertConfigurationIsValid();
        }
开发者ID:techvenky,项目名称:microservice-template,代码行数:7,代码来源:NancyBootstrapper.cs

示例2: Execute

        public void Execute(IContainer container)
        {
            log4net.Config.XmlConfigurator.Configure();

            container.Configure(x =>
            {
                x.Scan(scanner =>
                {
                    scanner.AssembliesFromApplicationBaseDirectory(assembly => assembly.GetName().Name.StartsWith("Example"));
                    scanner.AddAllTypesOf(typeof (IStartup));
                    scanner.AddAllTypesOf(typeof(IConsumer));
                    scanner.SingleImplementationsOfInterface();
                    scanner.WithDefaultConventions();
                });
                x.For<ILog>().Use(LogManager.GetLogger(typeof(StartupTask)));
            });

            foreach (var task in container.GetAllInstances<IStartup>())
            {
                task.Execute(container);
            }

            // must be done out of the normal configuration due to the dependence on the
            // scan for consumers having been completed.
            container.Inject(typeof(IServiceBus),
                ServiceBusFactory.New(sbc =>
                {
                    sbc.UseRabbitMq();
                    sbc.UseControlBus();
                    sbc.ReceiveFrom(ConfigurationManager.AppSettings["WebDenormalizerMessageQueue"]);
                    sbc.Subscribe(subs => subs.LoadFrom(container));
                }));
        }
开发者ID:tomsean,项目名称:EventSourcingTodo,代码行数:33,代码来源:StartupTask.cs

示例3: ExecuteEndTasks

 public void ExecuteEndTasks(IContainer nestedContainer)
 {
     foreach (var task in nestedContainer.GetAllInstances<IRunAfterEachRequest>())
     {
         task.Execute();
     }
 }
开发者ID:Rajiv-Kulkarni,项目名称:Failtracker.WindowsAuth,代码行数:7,代码来源:Global.asax.cs

示例4: GetArgumentValue

        private object GetArgumentValue(
            ParameterInfo parameter, 
            ArgumentCollection constructorArguments, 
            IContainer container)
        {
            object value;

            if (constructorArguments.Contains(parameter.Name))
            {
                value = constructorArguments[parameter.Name];
            }
            else if (parameter.ParameterType.IsArray)
            {
                var elementType = parameter.ParameterType.GetElementType();

                var arrayCastDelegate = ArrayCastDelegates[elementType];
                var instances = container.GetAllInstances(elementType).ToArray();

                value = arrayCastDelegate(instances);
            }
            else
            {
                value = container.GetInstance(parameter.ParameterType);
            }

            return value;
        }
开发者ID:bradleyjford,项目名称:inception,代码行数:27,代码来源:ContainerActivator.cs

示例5: ConfigureOnStartup

 public void ConfigureOnStartup(IContainer container)
 {
     var dependenciesToInitialized = container.GetAllInstances<IRequireConfigurationOnStartup>();
     foreach (var dependency in dependenciesToInitialized)
     {
         dependency.Configure();
     }
 }
开发者ID:rguerreiro,项目名称:MIXer.BackOffice,代码行数:8,代码来源:Bootstrapper.cs

示例6: Application_BeginRequest

 public void Application_BeginRequest()
 {
     Container = ObjectFactory.Container.GetNestedContainer();
     foreach (var task in Container.GetAllInstances<IRunOnEachRequest>())
     {
         task.Execute();
     }
 }
开发者ID:Defcoq,项目名称:YogamHealth,代码行数:8,代码来源:Global.asax.cs

示例7: Register

        public static void Register(IContainer container)
        {
            var mappingProfiles = container.GetAllInstances<Profile>();

            foreach (var profile in mappingProfiles)
            {
                Mapper.AddProfile(profile);
            }
        }
开发者ID:ChrisMissal,项目名称:atxc,代码行数:9,代码来源:MappingConfig.cs

示例8: ConfigureAutoMapper

 private static void ConfigureAutoMapper(IContainer container)
 {
     var configuration = container.TryGetInstance<IConfiguration>();
     if (configuration == null) return;
     //saying AutoMapper how to resolve services
     configuration.ConstructServicesUsing(container.GetInstance);
     foreach (var profile in container.GetAllInstances<Profile>())
     {
         configuration.AddProfile(profile);
     }
 }
开发者ID:rabbal,项目名称:AspNetMVCNTierTemp,代码行数:11,代码来源:ProjectObjectFactory.cs

示例9: InitializeInternal

        private static void InitializeInternal(IContainer container)
        {
            Mapper.Initialize(cfg =>
            {
                foreach (var profile in container.GetAllInstances<Profile>())
                {
                    cfg.AddProfile(profile);
                }

                cfg.ConstructServicesUsing(container.GetInstance);
            });
        }
开发者ID:calebjenkins,项目名称:presentations,代码行数:12,代码来源:AutoMapperBootstrapper.cs

示例10: RegisterDocumentStores

        internal UniformConfigurator RegisterDocumentStores(IContainer container)
        {
            UniformContext uniform = container.GetInstance<UniformContext>();
            foreach (IDocument document in container.GetAllInstances<IDocument>())
            {
                Type documentType = document.GetType();
                Type storeType = typeof (IDocumentStore<>).MakeGenericType(documentType);

                MethodInfo method = uniform.GetType().GetMethod("GetDocumentStore").MakeGenericMethod(documentType);
                container.Configure(config => config.For(storeType).Use(method.Invoke(uniform, null)));
            }

            return this;
        }
开发者ID:Ontropix,项目名称:whowhat,代码行数:14,代码来源:UniformConfigurator.cs

示例11: buildProfile

        private static IConventionProfile buildProfile(IContainer container, IEnumerable<Type> registries)
        {
            container.Configure(x =>
                {
                    registries.Each(c => x.For(typeof (IConventionRegistry)).Add(c));
                    x.For<IConventionProfile>().Singleton().Use<ConventionProfile>();
                });

            var conventionProfile = container.GetInstance<IConventionProfile>();
            foreach (var conventionRegistry in container.GetAllInstances<IConventionRegistry>())
            {
                conventionRegistry.Register(conventionProfile);
            }
            return conventionProfile;
        }
开发者ID:marcusswope,项目名称:MVCConventions,代码行数:15,代码来源:MVCConventions.cs

示例12: AppContext

 public AppContext(IContainer container)
 {
     _container = container;
     var databaseService = _container.GetInstance<IDatabaseService>();
     if (databaseService.IsServerConnectionOk())
     {
         foreach (var startupProcess in _container.GetAllInstances<IStartupProcess>())
         {
             startupProcess.Run();
         }
         MainForm = GetLoginForm();
     }
     else
     {
         MainForm = GetSqlServerConnectionForm();
     }
 }
开发者ID:aelhadi,项目名称:opencbs,代码行数:17,代码来源:AppContext.cs

示例13: RunOnServices

		private static void RunOnServices(IContainer container, Action<IService> action, Action starting, Action finishing, Action<Exception> onError)
		{
			starting();
			try
			{
				var services = container.GetAllInstances<IService>();
				foreach (IService service in services)
				{
					action(service);
				}
			}
			catch (Exception exception)
			{
				onError(exception);
				throw;
			}
			finishing();
		}
开发者ID:lakshithagit,项目名称:Target-Process-Plugins,代码行数:18,代码来源:ServiceManager.cs

示例14: InitializeInternal

        private static void InitializeInternal(IContainer container)
        {
            //var logger = Logger.Instance;

            //logger.Debug("Initializing Automapper");

            Mapper.Initialize(cfg =>
            {
                var profileNames = new List<string>();
                foreach (var profile in container.GetAllInstances<Profile>())
                {
                    profileNames.Add(profile.ProfileName);
                    cfg.AddProfile(profile);
                }

                //logger.Verbose("Added profiles: {ProfileName}", profileNames);

                cfg.ConstructServicesUsing(container.GetInstance);
            });
        }
开发者ID:kinpro,项目名称:ContosoUniversity,代码行数:20,代码来源:AutoMapperBootstrapper.cs

示例15: UseStructureMap

        public static IBusCreator UseStructureMap(this BusConfiguration configuration, Assembly handlerAssembly, IContainer container)
        {
            if (configuration == null) throw new ArgumentNullException("configuration");
            if (handlerAssembly == null) throw new ArgumentNullException("handlerAssembly");
            if (container == null) throw new ArgumentNullException("container");

            container.Configure(c =>
                                {
                                    c.For<IBus>().HybridHttpOrThreadLocalScoped().Use<MsmqBus>();
                                    c.Scan(a =>
                                           {
                                               a.Assembly(handlerAssembly);
                                               a.AddAllTypesOf<IMessageHandler>().NameBy(t => t.FullName);
                                           });
                                    c.SetAllProperties(a => a.Matching(p => p.PropertyType == typeof(IBus)));
                                });

            configuration.MessageCreator = container.GetInstance;
            configuration.RegisterHandlers(container.GetAllInstances<IMessageHandler>().ToArray());

            return new BusCreator(container);
        }
开发者ID:dstarosta,项目名称:GitProjects,代码行数:22,代码来源:BusConfigurationExtensions.cs


注:本文中的IContainer.GetAllInstances方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。