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


C# WindsorContainer.ResolveAll方法代码示例

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


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

示例1: Main

        static void Main(string[] args)
        {
            var bits = Environment.Is64BitProcess ? "64 bit" : "32 bit";
            Console.WriteLine($"Running {bits} process");
            //using windsor for convenience
            using (var container = new WindsorContainer())
            {
                container.Register(Classes.FromAssemblyInDirectory(new AssemblyFilter("."))
                                          .BasedOn<ISerializer>()
                                          .OrBasedOn(typeof(ISerializerStream))
                                          .WithServiceAllInterfaces()
                                          .LifestyleTransient());

                container.Register(Classes.FromAssemblyInDirectory(new AssemblyFilter("."))
                                          .BasedOn<IStreamTest>()
                                          .OrBasedOn(typeof(ITest))
                                          .WithServiceAllInterfaces()
                                          .LifestyleSingleton());

                var allSerializers = container.ResolveAll<ISerializer>();
                var allSerializerStreams = container.ResolveAll<ISerializerStream>();
                var allStreamTests = container.ResolveAll<IStreamTest>();

                var testExecutor = new TestExecutor();

                foreach (var serializerStream in allSerializerStreams)
                    foreach (var streamTest in allStreamTests)
                        testExecutor.ExecuteLargePropertyTest(streamTest, serializerStream);              
            }            
        }       
开发者ID:myarichuk,项目名称:SerializerLimits,代码行数:30,代码来源:Program.cs

示例2: LoadPatches

        protected virtual void LoadPatches() {
            patches = new List<IMvcPatch>();
            var patchIocFile = TargetFileSystem.ReadXml("ioc/patches.config", null,
                                                        new ReadXmlOptions{Merge = true});
            if (patchIocFile == null){
                patchIocFile = "<configuration />";
            }
            try{
                var patchIocResource = new StaticContentResource(patchIocFile);
                if (null != patchIocFile){

                    var container = new WindsorContainer(new XmlInterpreter(patchIocResource));
                    try{
                        foreach (var patch in container.ResolveAll<IMvcPatch>()){
                            patch.FileSystem = FileSystem;
                            patch.Manager = this;
                            patch.Identity = new SimplePackageIdentity(patch.Code);
                            patches.Add(patch);
                        }
                    }
                    finally{
                        container.Dispose();
                    }
                }
            }catch(Exception ex){
                throw new Exception("error in config:\r\n"+patchIocFile,ex);
            }
        }
开发者ID:Qorpent,项目名称:comdiv.oldcore,代码行数:28,代码来源:DefaultMvcPatchManager.cs

示例3: CanInstallHandlersInTheContainer

        public void CanInstallHandlersInTheContainer()
        {
            using (IWindsorContainer container = new WindsorContainer())
            {
                //This line just forces the domain events lib to be loaded, and handlers available in the app domain.
                IProcessEvents proc = new DailyActivityEventProcessor(new Mock<IRepository<DailyActivity>>().Object);

                container.Install(new HandlerInstaller(), new RepositoryInstaller());

                ProcessStarted started = new ProcessStarted(Guid.NewGuid(), Guid.NewGuid());
                var handlerType = typeof (IHandleEvent<>).MakeGenericType(started.GetType());

                IEnumerable<dynamic> handlers = container.ResolveAll(handlerType).Cast<dynamic>();

                Assert.IsNotNull(handlers);
                Assert.AreEqual(2, handlers.Count());

                var handler = handlers.FirstOrDefault(o => o.GetType() == typeof (DailyActivityEventProcessor));
                Assert.IsNotNull(handler);


            }


        }
开发者ID:happygrizzly,项目名称:C--Event-Processors-Example,代码行数:25,代码来源:HandlerInstallersTest.cs

示例4: Main

        static void Main(string[] args)
        {
            IWindsorContainer container = new WindsorContainer();

            BuildDependencies(container);

            var commanLineReaders = container.ResolveAll<ICommandLineReader>().ToList();

            bool exit = false;
            while (!exit)
            {
                var command = Console.ReadLine();
                if (command == "exit" || command == "quit")
                {
                    exit = true;
                    continue;
                }

                foreach (var commandReader in commanLineReaders)
                {
                    commandReader.Process(command);
                    break;
                }
            }
        }
开发者ID:kejto,项目名称:RobotWars,代码行数:25,代码来源:Program.cs

示例5: InstallAssemblies

        /// <summary>
        /// 	Installs the assemblies.
        /// </summary>
        /// <param name = "container">The container.</param>
        /// <param name = "assemblies">The assemblies.</param>
        public static void InstallAssemblies(this IIoCContainer container, Assembly[] assemblies)
        {
            //Contract.Requires(container != null);
            //Contract.Requires(assemblies != null);

            using (var registrationContainer = new WindsorContainer())
            {
                foreach (var assembly in assemblies)
                {
                    try
                    {
                        //container.Install(FromAssembly.Instance(assembly));
                        registrationContainer.Register(AllTypes.FromAssembly(assembly)
                                                       	.IncludeNonPublicTypes()
                                                       	.BasedOnAsService<IComponentInstaller>()
                                                       	.Configure(c => c.LifeStyle.Transient));
                    }
                    catch (Exception e)
                    {
                        var msg = String.Format("Could not load assembly '{0}' because related assembly can't be loaded. Exception details: {1}", assembly.FullName, e.Message);
                        _logger.Fatal(msg, e);
                        throw new Exception(msg);
                    }
                }

                foreach (var item in registrationContainer.ResolveAll<IComponentInstaller>())
                    item.Install(container, assemblies);
            }
        }
开发者ID:andriybilas,项目名称:MasterM,代码行数:34,代码来源:IoCContainerExtensions.cs

示例6: Main

        static void Main(string[] args) {

            //Load IoC container
            var container = new WindsorContainer();

            // Grab all IoC installers in Bin dir
            container.Install(
                FromAssembly.InDirectory(new AssemblyFilter(Environment.CurrentDirectory))
                );

            // Resolve all filters and order according to the order property
            var filters = container.ResolveAll<IFilter>().OrderBy(f => f.Order);

            // Resolve the registered pipeline implementation
            var pipeline = container.Resolve<IPipeline>();

            //Load and execute pipeline
            Console.WriteLine("Pipeline starting");

            foreach(var filter in filters) {
                pipeline.Register(filter);
            }

            pipeline.Execute(args[0]);

            Console.WriteLine("Pipeline completed");

        }
开发者ID:Marknumskull,项目名称:Azert.Pipeline,代码行数:28,代码来源:Program.cs

示例7: PluginsCanBeResolvedFromWindsor

 public void PluginsCanBeResolvedFromWindsor()
 {
     IWindsorContainer container = new WindsorContainer();
     InitializeWindsor(ref container);
     var cnt = container.ResolveAll<IPlugin>().Count(item => item != null);//count of somehow initialized plugins
     Assert.AreNotEqual(cnt,0,"Windsor container could not plugins have resolved");
 }
开发者ID:supermuk,项目名称:iudico,代码行数:7,代码来源:StartUpTests.cs

示例8: ContainerIsBeingDesposedProperly

 public void ContainerIsBeingDesposedProperly()
 {
     IWindsorContainer container = new WindsorContainer();
     InitializeWindsor(ref container);
     ILmsService service = container.Resolve<ILmsService>();
     container.Dispose();
     Assert.That(container.ResolveAll<Object>().Count(item => item != null) == 0);
 }
开发者ID:supermuk,项目名称:iudico,代码行数:8,代码来源:ShutDownTests.cs

示例9: CanResolveMoreThanSingleComponentForService

		public void CanResolveMoreThanSingleComponentForService()
		{
			IWindsorContainer container = new WindsorContainer()
				.AddComponent<IClock, IsraelClock>()
				.AddComponent<IClock, WorldClock>();

			IClock[] clocks = container.ResolveAll<IClock>();

			Assert.AreEqual(2, clocks.Length);
		}
开发者ID:ralescano,项目名称:castle,代码行数:10,代码来源:MultiResolveTests.cs

示例10: OnStart

 protected override void OnStart(string[] args)
 {
     var wc = new WindsorContainer();
     ServiceConfigurator.Begin(wc)
         .FinishConfiguration();
     _container = wc;
     foreach (IStartableService s in _container.ResolveAll<IStartableService>())
     {
         s.Start();
     }
 }
开发者ID:lafar6502,项目名称:cogmon,代码行数:11,代码来源:Service1.cs

示例11: CanGetAllValidators

        public void CanGetAllValidators()
        {
            WindsorContainer container = new WindsorContainer();
            container.Register(AllTypes.FromAssembly(typeof(IValidator).Assembly).Pick()
                .WithService.DefaultInterface());

            var validators = container.ResolveAll<IValidator>();

            Assert.IsNotNull(validators);
            Assert.AreEqual(3, validators.Count());
        }
开发者ID:AnthonySteele,项目名称:IoCComparison,代码行数:11,代码来源:WindsorTest.cs

示例12: CanUseMutliResolveWithGenericSpecialization

		public void CanUseMutliResolveWithGenericSpecialization()
		{
			IWindsorContainer container = new WindsorContainer()
				.AddComponent("demo", typeof (IRepository<>), typeof (DemoRepository<>))
				.AddComponent("trans", typeof(IRepository<>), typeof(TransientRepository<>));

			IRepository<IClock> resolve = container.Resolve<IRepository<IClock>>();
			Assert.IsNotNull(resolve);

			IRepository<IsraelClock>[] repositories = container.ResolveAll<IRepository<IsraelClock>>();
			Assert.AreEqual(2, repositories.Length);
		}
开发者ID:ralescano,项目名称:castle,代码行数:12,代码来源:MultiResolveTests.cs

示例13: TryLoadCorrectPlugin

 public void TryLoadCorrectPlugin()
 {
     IWindsorContainer container=new WindsorContainer();
     InitializeWindsor(ref container);
     var plugins = container.ResolveAll<IPlugin>();
     foreach (var plugin in plugins)
     {
         Assert.IsNotNull(plugin.BuildActions(),plugin.GetName());
         Assert.IsNotNull(plugin.BuildMenuItems(), plugin.GetName());
     }
     Assert.Pass("Every plugin can be accessed");
 }
开发者ID:supermuk,项目名称:iudico,代码行数:12,代码来源:PluginsLoadingTests.cs

示例14: TestXml

 public void TestXml()
 {
     var container = new WindsorContainer();
     container.Kernel.ComponentModelCreated += model => {
         if (model.Name == "MainClass2")
             model.Constructors.Remove(model.Constructors.First(c => c.Dependencies.Any(m => m.TargetType == typeof(IMyInterface))));
     };
     container.Install(Configuration.FromXml(new StaticContentResource(xmlConfig)));
     var objs = container.ResolveAll<IMyWindsorInterface>();
     Assert.AreEqual(1, objs.Count(o => o.Dep == null));
     Assert.AreEqual(1, objs.Count(o => o.Dep != null));
 }
开发者ID:ruanzx,项目名称:mausch,代码行数:12,代码来源:ResolveAllConstructors.cs

示例15: Bug

 public void Bug()
 {
     var container = new WindsorContainer();
     container.AddFacility<FactorySupportFacility>();
     container.Register(Component.For<IService>
                            ().ImplementedBy<Service1>().Named("1"));
     container.Register(Component.For<IService>
                            ().ImplementedBy<Service2>().Named("2"));
     container.Register(Component.For<IEnumerable<IService>>
                            ().UsingFactoryMethod(() => container.ResolveAll<IService>()));
     container.Register(Component.For<Consumer>());
     Assert.IsNotNull(container.Kernel.Resolve<Consumer>());
 }
开发者ID:ruanzx,项目名称:mausch,代码行数:13,代码来源:EnumerableRegistration.cs


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