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


C# UnityContainer.Resolve方法代码示例

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


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

示例1: Page_Load

 protected void Page_Load(object sender, EventArgs e)
 {
     IUnityContainer container = new UnityContainer();
     UnityConfigurationSection section = (UnityConfigurationSection)ConfigurationManager.GetSection("unity");
     section.Configure(container);
     if (Request["installation"] != null)
     {
         int installationid = Int32.Parse(Request["installation"]);
         userid = Int32.Parse(Request["userid"]);
         user = Request["user"];
         sservice = container.Resolve<IStatisticService>();
         IInstallationBL iinstall = container.Resolve<IInstallationBL>();
         imodel = iinstall.getInstallation(installationid);
         Dictionary<InstallationModel, List<InstallationState>> statelist = sservice.getInstallationState(imodel.customerid);
         StringBuilder str = new StringBuilder();
         str.Append("<table border = '1'><tr><th>Description</th><th>Messwert</th><th>Einheit</th></tr>");
         foreach (var values in statelist)
         {
             if(values.Key.installationid.Equals(installationid))
             {
                 foreach (var item in values.Value)
                 {
                      str.Append("<tr><td>" + item.description + "</td><td>" + item.lastValue + "</td><td>" + item.unit + "</td></tr>");
                 }
                 break;
             }
         }
         str.Append("</table>");
         anlagenzustand.InnerHtml = str.ToString();
     }
 }
开发者ID:daniel9992000,项目名称:bif5-sks-csharp,代码行数:31,代码来源:InstallationDetail.aspx.cs

示例2: OnStartup

        protected override void OnStartup(StartupEventArgs e)
        {
            IUnityContainer container = new UnityContainer();
            container.AddNewExtension<LazySupportExtension>();

            // Register grooveshark related stuff
            container.RegisterType<IGroovesharkClient, GroovesharkClientWrapper>(
                new ContainerControlledLifetimeManager(), 
                new InjectionMethod("Connect"));
            container.RegisterType<ISongProvider, GroovesharkSongProvider>(
                GroovesharkSongProvider.ProviderName, 
                new ContainerControlledLifetimeManager());
            container.RegisterType<ISongPlayer, GroovesharkSongPlayer>(
                GroovesharkSongProvider.ProviderName,
                new ContainerControlledLifetimeManager());

            // Register spotify/torshify related stuff
            container.RegisterType<ISongProvider, SpotifySongProvider>(
                SpotifySongProvider.ProviderName,
                new ContainerControlledLifetimeManager());
            container.RegisterType<ISongPlayer, TorshifySongPlayerClient>(
                SpotifySongProvider.ProviderName,
                new ContainerControlledLifetimeManager());
            container.RegisterType<ISpotifyImageProvider, TorshifyImageProvider>();

            // Aggregate provider that combines Grooveshark and Spotify players and providers
            container.RegisterType<ISongProvider, AggregateSongProvider>(new InjectionFactory(c =>
            {
                var a = new AggregateSongProvider(
                    c.Resolve<ISongProvider>(GroovesharkSongProvider.ProviderName),
                    c.Resolve<ISongProvider>(SpotifySongProvider.ProviderName));
                
                a.UnhandledException += (sender, args) =>
                {
                    Trace.WriteLine(args.Exception);
                    args.Handled = true;
                };

                return a;
            }));
            container.RegisterType<ISongPlayer, AggregateSongPlayer>(new InjectionFactory(c =>
            {
                return new AggregateSongPlayer(
                    c.Resolve<ISongPlayer>(GroovesharkSongProvider.ProviderName),
                    c.Resolve<ISongPlayer>(SpotifySongProvider.ProviderName));
            }));

            TorshifyServerProcessHandler torshifyServerProcess = new TorshifyServerProcessHandler();
            torshifyServerProcess.CloseServerTogetherWithClient = true;
            //torshifyServerProcess.Hidden = true;
            torshifyServerProcess.TorshifyServerLocation = Path.Combine(Environment.CurrentDirectory, "TRock.Music.Torshify.Server.exe");
            torshifyServerProcess.UserName = "<insert username>";
            torshifyServerProcess.Password = "<insert password>";
            torshifyServerProcess.Start();

            var provider = container.Resolve<ISongProvider>();

            MainWindow = container.Resolve<MainWindow>();
            MainWindow.Show();
        }
开发者ID:torshy,项目名称:TRock.Music,代码行数:60,代码来源:App.xaml.cs

示例3: InjectClassWithTwoConstructors

        public void InjectClassWithTwoConstructors()
        {
            int myInt = 37;
            string myStr = "Test";

            IUnityContainer container = new UnityContainer();

            //constructor without params
            container.Configure<InjectedMembers>().ConfigureInjectionFor<TestClass>(new InjectionConstructor());

            TestClass withOutCon = container.Resolve<TestClass>();
            Assert.IsFalse(withOutCon.StringConstructorCalled);
            Assert.IsFalse(withOutCon.IntConstructorCalled);
            //constructor with one param
            container.Configure<InjectedMembers>()
                .ConfigureInjectionFor<TestClass>("First",
                    new InjectionConstructor(myInt));

            TestClass myTestClass = container.Resolve<TestClass>("First");

            Assert.IsFalse(myTestClass.StringConstructorCalled);
            Assert.IsTrue(myTestClass.IntConstructorCalled);

            //constructor with one param
            container.Configure<InjectedMembers>()
               .ConfigureInjectionFor<TestClass>("Second",
                   new InjectionConstructor(myStr));

            TestClass myTestClass1 = container.Resolve<TestClass>("Second");
            
            Assert.IsFalse(myTestClass1.IntConstructorCalled);
            Assert.IsTrue(myTestClass1.StringConstructorCalled);
        }
开发者ID:CFMITL,项目名称:unity,代码行数:33,代码来源:InjectedMembersFixture.cs

示例4: Should_Only_Record_For_Types_Declared_In_Config_File

        public void Should_Only_Record_For_Types_Declared_In_Config_File()
        {
            var container = new UnityContainer().LoadConfiguration("BetamaxWithConfig");

            Assert.That(container.Resolve<SimpleWidgetService>().GetType().FullName, Is.StringEnding("DummyWidgetService"));
            Assert.That(container.Resolve<WidgetService>().GetType().FullName, Is.StringEnding("Proxy"));
        }
开发者ID:chakming,项目名称:Betamax.Net,代码行数:7,代码来源:BetamaxConfigurationExtensionsTests.cs

示例5: BuildUnityContainer

    private static IUnityContainer BuildUnityContainer()
    {
      var container = new UnityContainer();

      // register all your components with the container here
      // it is NOT necessary to register your controllers

      // e.g. container.RegisterType<ITestService, TestService>();
      container.RegisterType<UDI.EF.DAL.IEFContext, UDI.EF.DAL.EFContext>(new ContainerControlledLifetimeManager());
      container.Resolve<UDI.EF.DAL.IEFContext>();
      //container.RegisterType(typeof(IRepository<>), typeof(EFGenericRepository<>));
      //Bind the various domain model services and repositories that e.g. our controllers require   

      //Register interfaces in CORE
      container.RegisterType(typeof(UDI.CORE.Repositories.IRepository<>), typeof(UDI.EF.Repositories.EFRepositoryBase<>));
      container.RegisterType<UDI.CORE.Services.ICategoryService, UDI.CORE.Services.Impl.CategoryService>();
      container.RegisterType<UDI.CORE.Services.ICustomerService, UDI.CORE.Services.Impl.CustomerService>();
      container.RegisterType<UDI.CORE.Services.IOrderService, UDI.CORE.Services.Impl.OrderService>();
      container.RegisterType<UDI.CORE.Services.IProductService, UDI.CORE.Services.Impl.ProductService>();
      container.RegisterType<UDI.CORE.Services.IUserService, UDI.CORE.Services.Impl.UserService>();
      container.RegisterType<UDI.CORE.UnitOfWork.IUnitOfWork, UDI.EF.UnitOfWork.EFUnitOfWork>(new ContainerControlledLifetimeManager());
      container.Resolve<UDI.CORE.UnitOfWork.IUnitOfWork>();
      container.RegisterType<UDI.CORE.UnitOfWork.IUnitOfWorkManager, UDI.EF.UnitOfWork.EFUnitOfWorkManager>();
      //Register interfaces in EF
      container.RegisterType<UDI.EF.DAL.IEFContext, UDI.EF.DAL.EFContext>();

      //return container;
      RegisterTypes(container);

      return container;
    }
开发者ID:tuanva90,项目名称:mvccodefirst,代码行数:31,代码来源:Bootstrapper.cs

示例6: OnCreateContainer

        partial void OnCreateContainer(UnityContainer container)
        {
            var metadata = container.Resolve<IMetadataProvider>();
            var serializer = container.Resolve<ITextSerializer>();

            var commandBus = new CommandBus(new TopicSender(azureSettings.ServiceBus, Topics.Commands.Path), metadata, serializer);
            var topicSender = new TopicSender(azureSettings.ServiceBus, Topics.Events.Path);
            container.RegisterInstance<IMessageSender>(topicSender);
            var eventBus = new EventBus(topicSender, metadata, serializer);

            var commandProcessor = new CommandProcessor(new SubscriptionReceiver(azureSettings.ServiceBus, Topics.Commands.Path, Topics.Commands.Subscriptions.All), serializer);

            container.RegisterInstance<ICommandBus>(commandBus);
            container.RegisterInstance<IEventBus>(eventBus);
            container.RegisterInstance<ICommandHandlerRegistry>(commandProcessor);
            container.RegisterInstance<IProcessor>("CommandProcessor", commandProcessor);

            RegisterRepository(container);
            RegisterEventProcessors(container);

            // message log
            var messageLogAccount = CloudStorageAccount.Parse(azureSettings.MessageLog.ConnectionString);

            container.RegisterInstance<IProcessor>("EventLogger", new AzureMessageLogListener(
                new AzureMessageLogWriter(messageLogAccount, azureSettings.MessageLog.TableName),
                new SubscriptionReceiver(azureSettings.ServiceBus, Topics.Events.Path, Topics.Events.Subscriptions.Log)));

            container.RegisterInstance<IProcessor>("CommandLogger", new AzureMessageLogListener(
                new AzureMessageLogWriter(messageLogAccount, azureSettings.MessageLog.TableName),
                new SubscriptionReceiver(azureSettings.ServiceBus, Topics.Commands.Path, Topics.Commands.Subscriptions.Log)));
        }
开发者ID:garystanford,项目名称:cqrs-journey-code,代码行数:31,代码来源:ConferenceProcessor.Azure.cs

示例7: OnStartup

        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);

            var container = new UnityContainer();

            container.RegisterType<IUdpClientServer, UdpClientServer>(new ContainerControlledLifetimeManager());

            var serverAddress = ConfigurationManager.AppSettings.Get("ServerAddress");
            var serverPort = int.Parse(ConfigurationManager.AppSettings.Get("ServerPort"));
            container.RegisterInstance<IChannelConfig>(ChannelNames.Server, new ChannelConfig { Address = serverAddress, Port = serverPort }, new ContainerControlledLifetimeManager());
            container.RegisterType<ICommunicationChannel, UdpCommunicationChannel>(
                ChannelNames.Server,
                new ContainerControlledLifetimeManager(),
                new InjectionFactory(c => new UdpCommunicationChannel(c.Resolve<IUdpClientServer>(), c.Resolve<IChannelConfig>(ChannelNames.Server))));

            var clientAddress = ConfigurationManager.AppSettings.Get("ClientAddress");
            var clientPort = int.Parse(ConfigurationManager.AppSettings.Get("ClientPort"));
            container.RegisterInstance<IChannelConfig>(ChannelNames.Client, new ChannelConfig { Address = clientAddress, Port = clientPort }, new ContainerControlledLifetimeManager());
            container.RegisterType<ICommunicationChannel, UdpCommunicationChannel>(
                ChannelNames.Client,
                new ContainerControlledLifetimeManager(),
                new InjectionFactory(c => new UdpCommunicationChannel(c.Resolve<IUdpClientServer>(), c.Resolve<IChannelConfig>(ChannelNames.Client))));

            container.RegisterType(typeof(IService<,>), typeof(Service<,>), new ContainerControlledLifetimeManager());
            container.RegisterType(typeof(ITopic<>), typeof(Topic<>), new ContainerControlledLifetimeManager());

            var ch = container.Resolve<ICommunicationChannel>(ChannelNames.Client);
            ch.SendMessage(new UserQuery("xxx"));

            container.RegisterType<MainWindowViewModel, MainWindowViewModel>(new ContainerControlledLifetimeManager());
            container.RegisterType<MainWindow>(new ContainerControlledLifetimeManager());

            container.Resolve<MainWindow>().Show();
        }
开发者ID:pgdotnet,项目名称:RxWorkshop,代码行数:35,代码来源:App.xaml.cs

示例8: LargeBatchInsert

        private static async Task<string> LargeBatchInsert()
        {
            IUnityContainer container = new UnityContainer();
            UnityApplicationFrameworkDependencyResolver resolver = new UnityApplicationFrameworkDependencyResolver(container);

            resolver
                .UseCore(defaultTraceLoggerMinimumLogLevel: LogLevelEnum.Verbose)
                .UseAzure();

            var resourceManager = container.Resolve<IAzureResourceManager>();
            var tableStorageRepositoryFactory = container.Resolve<ITableStorageRepositoryFactory>();
            var table = tableStorageRepositoryFactory.CreateAsynchronousNoSqlRepository<SampleEntity>(StorageAccountConnectionString, TableName);
            await resourceManager.CreateIfNotExistsAsync(table);

            string partitionKey = Guid.NewGuid().ToString();
            List<SampleEntity> entities = new List<SampleEntity>();
            for (int item = 0; item < 725; item++)
            {
                entities.Add(new SampleEntity
                {
                    Name = $"Name {item}",
                    PartitionKey = partitionKey,
                    RowKey = Guid.NewGuid().ToString()
                });
            }

            await table.InsertBatchAsync(entities);
            Console.WriteLine($"Inserted 725 items into partition {partitionKey}");
            return partitionKey;            
        }
开发者ID:JamesRandall,项目名称:AccidentalFish.ApplicationSupport,代码行数:30,代码来源:Program.cs

示例9: Main

        static void Main(string[] args)
        {
            int money;
            using (IUnityContainer container = new UnityContainer())
            {
                UnityConfigurationSection section =
                    (UnityConfigurationSection)ConfigurationManager.GetSection("unity");

                section.Configure(container,"Employee");

                Salary ms1 = container.Resolve<Salary>();

                money = ms1.Calculate(80,100,1);
                Console.WriteLine("Unity =>" + money);

                section.Configure(container,"Boss");

                ms1 = container.Resolve<Salary>();

                money = ms1.Calculate(80,100,1);
                Console.WriteLine("Boss =>" + money);

                Console.ReadKey();
               //test
            }
        }
开发者ID:Yamesz,项目名称:Training-Unity_Application_Block,代码行数:26,代码来源:Program.cs

示例10: UnityWithConfiguration

        private void UnityWithConfiguration()
        {
            // Create and populate a new Unity container from configuration            
            UnityConfigurationSection UnityConfigurationSectionObject = (UnityConfigurationSection)ConfigurationManager.GetSection("UnityBlockConfiguration");
            IUnityContainer UnityContainerObject = new UnityContainer();

            UnityConfigurationSectionObject.Containers["ContainerOne"].Configure(UnityContainerObject);
            Console.WriteLine("\nRetrieved the populated Unity Container.");

            // Get the logger to write a message and display the result. No name in config file.
            ILogger ILoggerInstance = UnityContainerObject.Resolve < ILogger>();            
            Console.WriteLine("\n" + ILoggerInstance.WriteMessage("HELLO Default UNITY!"));

            // Resolve an instance of the appropriate class registered for ILogger 
            // Using the specified mapping name in the configuration file (may be empty for the default mapping)
            ILoggerInstance = UnityContainerObject.Resolve<ILogger>("StandardLoggerMappedInConfig");
            
            // Get the logger to write a message and display the result
            Console.WriteLine("\n" + ILoggerInstance.WriteMessage("HELLO StandardLogger!"));
            
            // Resolve an instance of the appropriate class registered for ILogger 
            // Using the specified mapping name (may be empty for the default mapping)
            ILoggerInstance = UnityContainerObject.Resolve<ILogger>("SuperFastLoggerMappedInConfig");
            
            // Get the logger to write a message and display the result
            Console.WriteLine("\n" + ILoggerInstance.WriteMessage("HELLO SuperFastLogger!"));

            // Constructor Injection.
            // Resolve an instance of the concrete MyObjectWithInjectedLogger class 
            // This class contains a reference to ILogger in the constructor parameters 
            MyObjectWithInjectedLogger MyObjectWithInjectedLoggerInstance = UnityContainerObject.Resolve<MyObjectWithInjectedLogger>();
            // Get the injected logger to write a message and display the result
            Console.WriteLine("\n" + MyObjectWithInjectedLoggerInstance.GetObjectStringResult());

            // Throws error as we are trying to create instance for interface.
            //IMyInterface IMyInterfaceObject = UnityContainerObject.Resolve<IMyInterface>();

            IMyInterface IMyInterfaceObject = UnityContainerObject.Resolve<IMyInterface>();
            Console.WriteLine("\n" + IMyInterfaceObject.GetObjectStringResult());

            //If we are not sure whether a named registration exists for an object, 
            // we can use the ResolveAll method to obtain a list of registrations and mappings, and then check for the object we need in the list returned by this method. 
            // However, this will cause the container to generate all the objects for all named registrations for the specified object type, which will affect performance.
            IEnumerable<object> IEnumerableObjects = UnityContainerObject.ResolveAll(typeof(ILogger));
            int i = 0;
            foreach (ILogger foundObject in IEnumerableObjects)
            {
                // Convert the object reference to the "real" type
                ILogger theObject = foundObject as ILogger;
                i++;
                if (null != theObject)
                {
                    Console.WriteLine(theObject.WriteMessage("Reading Object " + i.ToString()));
                }
            }
            
            UnityContainerObject.Teardown(IMyInterfaceObject);

            Console.ReadLine();
        }
开发者ID:mac10688,项目名称:PublicWorkspace,代码行数:60,代码来源:Program.cs

示例11: Main

        static void Main(string[] args)
        {
            UnityContainer container = new UnityContainer();
            container.RegisterType<IBankAccount, BankAccount>();
            container.RegisterType<IBankAccountService, BankAccountService>();
            container.RegisterType<IDeposit, Deposit>();
            container.RegisterType<ITransfer, Transfer>();
            container.RegisterType<IServiceFeeDeduction, ServiceFeeDeduction>();

            Random rand = new Random();
            var number = rand.Next(100000000, 999999999);
            BankAccount savings = new SavingsAccount()
            {
                AccountNumber = number,
                Balance = (decimal)8904.67,
                FreeTransactions = 21
            };
            ShowSavingsStatement(savings);

            Deposit dep = container.Resolve<Deposit>();
            dep.DepositFunds(savings, (decimal)400.00);
            WriteYellowLine("Deposit was successful");
            ShowSavingsStatement(savings);

            ServiceFeeDeduction fee = container.Resolve<ServiceFeeDeduction>();
            fee.DeductServiceFee(savings);
            WriteYellowLine("Deduction was successful");
            ShowSavingsStatement(savings);
        }
开发者ID:mncwabelindo,项目名称:solid,代码行数:29,代码来源:Program.cs

示例12: Configuration

        public void Configuration(IAppBuilder app)
        {
            HttpConfiguration config = new HttpConfiguration();

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            var container = new UnityContainer();
            this.RegisterTypes(container);

            config.Formatters.JsonFormatter.SerializerSettings.ContractResolver = new CamelCasePropertyNamesContractResolver();

            var settings = new JsonSerializerSettings();
            settings.ContractResolver = new SignalRContractResolver();
            var serializer = JsonSerializer.Create(settings);
            GlobalHost.DependencyResolver.Register(typeof(JsonSerializer), () => serializer);
            JsonConvert.DefaultSettings = () => new JsonSerializerSettings
            {
                Formatting = Formatting.Indented,
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            GlobalHost.DependencyResolver.Register(typeof(GameHub), () => new GameHub(container.Resolve<GameService>(), container.Resolve<ChatService>()));
            app.MapSignalR(new HubConfiguration
            {
                EnableDetailedErrors = true
            });

            this.ConfigureOAuth(app);
        }
开发者ID:Valchris,项目名称:Tdd,代码行数:31,代码来源:Startup.cs

示例13: Login

        public ActionResult Login(string returnUrl)
        {


       //     Users curUser = new Users();
           // var dd = curUser.GetALL();
            IUnityContainer container = new UnityContainer();
            #region Ilogger
            //        container.RegisterType<ILogger, ConsoleLogger>();

            //        ILogger logger = container.Resolve<ILogger>();

            //string dd=        logger.Log("Have a look!");


            //container.RegisterType<ILogger, NullLogger>();

            //ILogger logger2 = container.Resolve<ILogger>();
            //string dd2 = logger2.Log("Have a look!"); 
            #endregion

            container.RegisterType<IOrder, CommonOrder>(new ContainerControlledLifetimeManager());

            IOrder order = container.Resolve<IOrder>();
            order.Discount = 0.8;


            IOrder order2 = container.Resolve<IOrder>();
            string dd = order2.DumpDiscount();

            ViewBag.ReturnUrl = returnUrl;
            return View();
        }
开发者ID:caicaishen,项目名称:netTest,代码行数:33,代码来源:AccountController.cs

示例14: Main

        static void Main(string[] args)
        {
            IUnityContainer unityContainer = new UnityContainer();
            IoCConvention.RegisterByConvention(unityContainer);

            var foobar = unityContainer.Resolve<IFooBar>();
            Console.WriteLine(foobar.GetData());

            var fooFactory = unityContainer.Resolve<IFooFactory>();
            var foo1 = fooFactory.Create("1");
            var foo2 = fooFactory.Create("2");
            
            Console.WriteLine(foo1.GetData());
            Console.WriteLine(foo2.GetData());

            var fooCustomFactory = unityContainer.Resolve<IFooCustomFactory>();
            var fooCustom1 = fooCustomFactory.Create("CustomName1");
            var fooCustom2 = fooCustomFactory.Create("CustomName2");

            Console.WriteLine(fooCustom1.GetData());
            Console.WriteLine(fooCustom2.GetData());

            var fooGenericString = unityContainer.Resolve<IFooGeneric<string>>();
            Console.WriteLine(fooGenericString.GetData("dataType"));

            var fooGenericInt = unityContainer.Resolve<IFooGeneric<int>>();
            Console.WriteLine(fooGenericInt.GetData(1));


            Console.ReadLine();
        }
开发者ID:nyghtrocker,项目名称:Blog,代码行数:31,代码来源:Program.cs

示例15: OnCreateContainer

        partial void OnCreateContainer(UnityContainer container)
        {
            var serializer = container.Resolve<ITextSerializer>();
            var metadata = container.Resolve<IMetadataProvider>();

            var commandBus = new CommandBus(new MessageSender(Database.DefaultConnectionFactory, "SqlBus", "SqlBus.Commands"), serializer);
            var eventBus = new EventBus(new MessageSender(Database.DefaultConnectionFactory, "SqlBus", "SqlBus.Events"), serializer);

            var commandProcessor = new CommandProcessor(new MessageReceiver(Database.DefaultConnectionFactory, "SqlBus", "SqlBus.Commands"), serializer);
            var eventProcessor = new EventProcessor(new MessageReceiver(Database.DefaultConnectionFactory, "SqlBus", "SqlBus.Events"), serializer);

            container.RegisterInstance<ICommandBus>(commandBus);
            container.RegisterInstance<IEventBus>(eventBus);
            container.RegisterInstance<ICommandHandlerRegistry>(commandProcessor);
            container.RegisterInstance<IProcessor>("CommandProcessor", commandProcessor);
            container.RegisterInstance<IEventHandlerRegistry>(eventProcessor);
            container.RegisterInstance<IProcessor>("EventProcessor", eventProcessor);

            // Event log database and handler.
            container.RegisterType<SqlMessageLog>(new InjectionConstructor("MessageLog", serializer, metadata));
            container.RegisterType<IEventHandler, SqlMessageLogHandler>("SqlMessageLogHandler");
            container.RegisterType<ICommandHandler, SqlMessageLogHandler>("SqlMessageLogHandler");

            RegisterRepository(container);
            RegisterEventHandlers(container, eventProcessor);
        }
开发者ID:HernanDL,项目名称:cqrs-journey-code,代码行数:26,代码来源:ConferenceProcessor.Local.cs


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