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


C# WindsorContainer.Resolve方法代码示例

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


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

示例1: it_should_add_custom_header_to_headers_collection_for_delayed_messages

        public void it_should_add_custom_header_to_headers_collection_for_delayed_messages()
        {
            using (var container = new WindsorContainer(new XmlInterpreter()))
            {
                container.Register(Component.For<ICustomizeOutgoingMessages>().ImplementedBy<AppIdentityCustomizer>().LifeStyle.Is(LifestyleType.Transient));
                new RhinoServiceBusConfiguration()
                    .UseCastleWindsor(container)
                    .Configure();
                var transport = container.Resolve<ITransport>();
                MsmqCurrentMessageInformation currentMessageInformation = null;
                var waitHandle = new ManualResetEvent(false);
                transport.MessageArrived += messageInfo =>
                {
                    currentMessageInformation = (MsmqCurrentMessageInformation) messageInfo;
                    waitHandle.Set();
                    return true;
                };
                var builder = container.Resolve<IMessageBuilder<Message>>();
                Message afterBuild = null;
                builder.MessageBuilt += msg => afterBuild = msg;

                using (var bus = container.Resolve<IStartableServiceBus>())
                {
                    bus.Start();
                    DateTime beforeSend = DateTime.Now;
                    bus.DelaySend(bus.Endpoint, DateTime.Now.AddMilliseconds(250), "testmessage");
                    waitHandle.WaitOne(TimeSpan.FromSeconds(30));
                    Assert.True((DateTime.Now - beforeSend).TotalMilliseconds >= 250);
                }
                Assert.NotNull(afterBuild);
                var headers = afterBuild.Extension.DeserializeHeaders();
                Assert.Equal("corey", headers["user-id"]);
                Assert.Equal("corey", currentMessageInformation.Headers["user-id"]);
            }
        }
开发者ID:JackWangCUMT,项目名称:rhino-esb,代码行数:35,代码来源:CanCustomizeOutgoingMessagesWithMsmq.cs

示例2: Main

        // Models singleton over transient instance models
        static void Main(string[] args)
        {
            IWindsorContainer container =
                new WindsorContainer(new XmlInterpreter("windsor.config"));

            //IWindsorContainer container = CreateContainer();

            IBar bar = container.Resolve<IBar>();

            if (bar != null)
            {
                bar.DisplayTime();
            }
            container.Release(bar);

            // Mimic a time delay.
            System.Threading.Thread.Sleep(2000);

            IBar bar2 = container.Resolve<IBar>();

            if (bar2 != null)
            {
                bar2.DisplayTime();
            }

            container.Release(bar2);

            Console.Write("Press <ENTER> to exit...");
            Console.ReadLine();
        }
开发者ID:lozanotek,项目名称:opensource,代码行数:31,代码来源:Program.cs

示例3: CanCreateDuplexProxyWithCallbackType

        public void CanCreateDuplexProxyWithCallbackType()
        {
            IWindsorContainer localContainer = new WindsorContainer();

            localContainer.AddFacility<WcfFacility>();

            DuplexClientModel model = new DuplexClientModel
            {
                Endpoint = WcfEndpoint.ForContract<IServiceWithCallback>()
                    .BoundTo(new NetTcpBinding())
                    .At("net.tcp://localhost/ServiceWithCallback")
            }.WithCallback<ICallbackService>();

            localContainer.Register(WcfClient.ForChannels(model));

            localContainer.Register(Component.For<ICallbackService>()
                                        .ImplementedBy<CallbackService>());

            var callbackService = localContainer.Resolve<ICallbackService>();

            Assert.AreEqual(0, ((CallbackService)callbackService).ValueFromTheOtherSide);

            IServiceWithCallback proxy = localContainer.Resolve<IServiceWithCallback>();
            proxy.DoSomething(21);

            Assert.IsAssignableFrom(typeof(CallbackService), callbackService);
            Assert.AreEqual(42, ((CallbackService)callbackService).ValueFromTheOtherSide);
        }
开发者ID:bwegman,项目名称:Castle.Facilities.Wcf,代码行数:28,代码来源:DuplexClientFixture.cs

示例4: ResolvingPerThreadComponents_NewInstanceIsCreatedForEachThread

        public void ResolvingPerThreadComponents_NewInstanceIsCreatedForEachThread()
        {
            IWindsorContainer container = new WindsorContainer();

             container.Register(
                 Component.For<IRepository<Client>>().ImplementedBy<ClientRepository>().LifeStyle.PerThread);

             Task firstTask = Task.Factory.StartNew(() =>
             {
                 var repository = container.Resolve<IRepository<Client>>();
                 var secondRepository = container.Resolve<IRepository<Client>>();

                 Assert.AreSame(repository, secondRepository);
             });

             Task secondTask = Task.Factory.StartNew(() =>
             {
                 var repository = container.Resolve<IRepository<Client>>();
                 var secondRepository = container.Resolve<IRepository<Client>>();

                 Assert.AreSame(repository, secondRepository);
             });

             Task.WaitAll(firstTask, secondTask);

             container.Dispose();
        }
开发者ID:BravoAlpha,项目名称:ALapAroundIoCContainersDemo,代码行数:27,代码来源:PerThread.cs

示例5: Main

 private static void Main(string[] args)
 {
     using (var container = new WindsorContainer())
     {
         container.Install(new AppInstaller());
         do
         {
             IOutputGenerator myClass;
             switch (Console.ReadLine())
             {
                 case "1":
                     myClass = container.Resolve<ReverseEvenNumberGenerator>();
                     break;
                 case "2":
                     myClass = container.Resolve<Class1>();
                     break;
                 case "3":
                     myClass = container.Resolve<OddNumberGenerator>();
                     break;
                 default:
                     return;
             }
             Console.WriteLine(myClass.GenerateOutput());
         } while (true);
     }
 }
开发者ID:AaronWells,项目名称:Interview,代码行数:26,代码来源:Program.cs

示例6: TestBasicOperations

		public void TestBasicOperations()
		{
			WindsorContainer container = new WindsorContainer(new DefaultConfigurationStore());

			container.AddFacility("transactionmanagement", new TransactionFacility());

			container.Register(Component.For<ITransactionManager>().ImplementedBy<MockTransactionManager>().Named("transactionmanager"));

			container.Register(Component.For<CustomerService>().Named("services.customer"));

			CustomerService service = container.Resolve<CustomerService>("services.customer");

			service.Insert("TestCustomer", "Rua P Leite, 33");

			MockTransactionManager transactionManager = container.Resolve<MockTransactionManager>("transactionmanager");

			Assert.AreEqual(1, transactionManager.TransactionCount);
			Assert.AreEqual(1, transactionManager.CommittedCount);
			Assert.AreEqual(0, transactionManager.RolledBackCount);

			try
			{
				service.Delete(1);
			}
			catch (Exception)
			{
				// Expected
			}

			Assert.AreEqual(2, transactionManager.TransactionCount);
			Assert.AreEqual(1, transactionManager.CommittedCount);
			Assert.AreEqual(1, transactionManager.RolledBackCount);
		}
开发者ID:ThatExtraBit,项目名称:Castle.Facilities.AutomaticTransactionManagement,代码行数:33,代码来源:TransactionTestCase.cs

示例7: CanInstallServicesInTheContainer

        public void CanInstallServicesInTheContainer()
        {
            IWindsorContainer container = new WindsorContainer()
                .AddFacility<TypedFactoryFacility>();

            container.Install(new ServiceInstaller());

            IMonitor monitor = container.Resolve<IMonitor>();
            IMonitor monitor2 = container.Resolve<IMonitor>();
            
            Assert.IsInstanceOf<MonitorService>(monitor);
            Assert.AreSame(monitor, monitor2);

            container.Release(monitor);
            container.Release(monitor2);

            //check dependencies also
            IEventDispatcher dispatcher1 = container.Resolve<IEventDispatcher>();
            IEventDispatcher dispatcher2 = container.Resolve<IEventDispatcher>();

            Assert.IsInstanceOf<EventDispatcher>(dispatcher1);
            Assert.AreSame(dispatcher1, dispatcher2);

            container.Release(dispatcher1);
            container.Release(dispatcher2);

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

示例8: Main

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

            container.Install(FromAssembly.This());

            var client = container.Resolve<IQuilt4NetClient>();
            client.WebApiClient.WebApiRequestEvent += WebApiClientWebApiRequestEvent;
            client.WebApiClient.WebApiResponseEvent += WebApiClient_WebApiResponseEvent;
            client.WebApiClient.AuthorizationChangedEvent += WebApiClient_AuthorizationChangedEvent;

            var business1 = container.Resolve<ISomeBusiness1>();
            var business2 = container.Resolve<ISomeBusiness2>();

            try
            {
                business1.Execute();
                business2.Execute();
            }
            catch (Exception exception)
            {
                Console.WriteLine("Exception: " + exception.Message);
            }

            //business1.Dispose();
            container.Dispose();

            Console.WriteLine("Press any key to exit...");
            Console.ReadKey();
        }
开发者ID:Quilt4,项目名称:Quilt4Net,代码行数:30,代码来源:Program.cs

示例9: ProcessTransactionService

 public ProcessTransactionService()
 {
     var container = new WindsorContainer(new XmlInterpreter(new ConfigResource("castle")));
     _accountRepository = container.Resolve<IAccountRepository>();
     _transactionsRepository = container.Resolve<ITransactionsRepository>();
     _paymentGateway = container.Resolve<IPaymentGateway>();
 }
开发者ID:olcayseker,项目名称:Logging-Interception-demo,代码行数:7,代码来源:ProcessTransactionService.cs

示例10: Main

        public static void Main(string[] args)
        {
            var container = new WindsorContainer();
            container.Register (
                Component.For<ManagerService>()
                    .LifeStyle.Singleton);

            container.Register (
                Component.For<UnmanagedService>()
                    .Interceptors<ManagerService>());

            var managerService = container.Resolve<ManagerService>();
            managerService.Start ();

            var unmanagedSvc = container.Resolve<UnmanagedService>();
            unmanagedSvc.Start ();

            Console.WriteLine ("Press enter to stop the service");
            Console.ReadLine ();

            managerService.Stop ();
            unmanagedSvc.Stop ();

            container.Dispose ();
        }
开发者ID:jmloeffler,项目名称:netManage,代码行数:25,代码来源:Main.cs

示例11: PizzaController

 public PizzaController()
 {
     CriarMapeamentosDto();
     _container = FabricaContainer.InicializarContainer();
     _ingredienteServico = _container.Resolve<IIngredienteServico>();
     _pizzaServico = _container.Resolve<IPizzaServico>();
 }
开发者ID:saitodisse,项目名称:MyPizza,代码行数:7,代码来源:PizzaController.cs

示例12: WorkerRole

        public WorkerRole()
        {
            _pulsers = Pulsers.FromAssembly(Assembly.GetAssembly(typeof(ImportFileProcessed)))
                .ToList();


            var container = new WindsorContainer();

            _configurationValueProvider = new AzureConfigurationValueProvider();
            SetupDi(container, _configurationValueProvider, _pulsers.ToArray());
            _pulserPublisher = container.Resolve<PulserPublisher>();
            _orchestrator = container.Resolve<Orchestrator>();

            // insert the list here
            var keyValueStore = container.Resolve<IDynamoStore>();
            var blob = new SimpleBlob()
            {
                Body = Assembly.GetExecutingAssembly()
                    .GetManifestResourceStream("BeeHive.Sample.FileImport.Worker.Data.SampleData.txt"),
                Id = "FileDrop/ImportFiles/SampleData.txt",
                LastModofied = DateTimeOffset.Now
            };
            keyValueStore.UpsertAsync(blob);

            // add one topic that will not be created automagically by orchestrator
            // because no actor registered against it
            var q = container.Resolve<IEventQueueOperator>();

            q.CreateQueueAsync("NewIndexUpserted").Wait();



        }
开发者ID:csuffyy,项目名称:BeeHive,代码行数:33,代码来源:WorkerRole.cs

示例13: Main

        static void Main(string[] args)
        {
            var ticks = DateTime.Now.Ticks;

            Console.WriteLine("Start : {0}", GetTimeElapsedSince(ticks));

            var container = new WindsorContainer();
            Console.WriteLine("Container created : {0}", GetTimeElapsedSince(ticks));

            container.Install(
                new DummyInstaller(),
                new NestedInstaller());

            Console.WriteLine("Types registered [{1}] : {0}", GetTimeElapsedSince(ticks), 1);

            var dummy = container.Resolve<IDummy100Service>();
            Console.WriteLine(dummy);
            Console.WriteLine("Resolved IDummy100Service : {0}", GetTimeElapsedSince(ticks));

            var nested = container.Resolve<INested0Service>();
            Console.WriteLine(nested);
            Console.WriteLine("Resolved INested0Service : {0}", GetTimeElapsedSince(ticks));

            Console.ReadKey();
        }
开发者ID:NashDotNet,项目名称:lab-dependency-injection,代码行数:25,代码来源:Program.cs

示例14: ResolveRepositories

        public void ResolveRepositories()
        {
            IWindsorContainer container = new WindsorContainer();
            container.Install(FromAssembly.This());

            var clientRepository = container.Resolve<IRepository<Client>>();
            var courseRepository = container.Resolve<IRepository<Course>>();
        }
开发者ID:BravoAlpha,项目名称:ALapAroundIoCContainersDemo,代码行数:8,代码来源:Conventions.cs

示例15: ResolveNamedNotifiers

        public void ResolveNamedNotifiers()
        {
            IWindsorContainer container = new WindsorContainer();
            container.Install(FromAssembly.This());

            var emailNotifier = container.Resolve<IRegistrationNotifier>("EmailNotifier");
            var smsNotifier = container.Resolve<IRegistrationNotifier>("SmsNotifier");
        }
开发者ID:BravoAlpha,项目名称:ALapAroundIoCContainersDemo,代码行数:8,代码来源:Conventions.cs


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