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


C# IContainer.Inject方法代码示例

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


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

示例1: 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

示例2: GetMainForm

 private static Form GetMainForm(IContainer container)
 {
     var mainForm = new WorkflowChooserView();
     container.Inject<IWorkflowChooserView>(mainForm);
     var presenter = container.GetInstance<WorkflowChooserPresenter>();
     presenter.Run();
     return mainForm;
 }
开发者ID:jagui,项目名称:LessonsLearned,代码行数:8,代码来源:AppContext.cs

示例3: StructureMapResolver

        public StructureMapResolver(IContainer container)
            : base(container)
        {
            if (container == null)
                throw new ArgumentNullException("container");

            _container = container;
            _container.Inject(typeof(IHttpControllerActivator), this);
        }
开发者ID:ChrisMissal,项目名称:atxc,代码行数:9,代码来源:StructureMapResolver.cs

示例4: Start

        public void Start()
        {
            _container = CreateContainer();
            _bus = CreateBus(_container);
            _container.Inject(_bus);
            _bus.Start();

            var rdb = _container.GetInstance<ReadStoreDb>();
            var wdb = _container.GetInstance<MyContext>();
            rdb.Database.Initialize(true);
            wdb.Database.Initialize(true);

            Thread.Sleep(2000);

            DoStuff();
        }
开发者ID:Liteolika,项目名称:NetOn,代码行数:16,代码来源:DomainService.cs

示例5: Register

        public override void Register(IContainer container, List<SiteRoute> routes, ViewEngineCollection viewEngines, ModelBinderDictionary modelBinders, ICollection<Asset> globalAssets)
        {
            /*
             <svc:include  name="LiteralWidget">
            &lt;div class="widget settings area"&gt;
            &lt;h3&gt;Windows Live Writer Workaround&lt;/h3&gt;
            &lt;a href="/WLWWorkaround/WLWWorkaround"&gt;Activate/Disable&lt;/a&gt;
            &lt;/div&gt;
            </svc:include>
             */

            container.Inject(typeof(IAuthenticateService), new WLWWorkaroundAuthenticateService());

            RegisterController<WLWWorkaroundController>(container);
            RegisterViewWidget(container, "AdminWLWWorkaround.aspx");

            routes.Insert(0, new SiteRoute()
             {
                 Name = "WLWWorkaround",
                 Route = new Route("WLWWorkaround/{Action}",
                   new RouteValueDictionary(new { controller = "WLWWorkaround", action = "Index" }), new MvcRouteHandler()),
                 Merit = (int)MeritLevel.Max
             });
        }
开发者ID:erikzaadi,项目名称:AtomSitePlugins,代码行数:24,代码来源:WLWWorkaroundPlugin.cs

示例6: RegisterCustomControllers

 private static void RegisterCustomControllers(IContainer container)
 {
     container.Inject(typeof(ITagRepository), new TagRepository());
     container.Inject(typeof(ISpeakerRepository), new SpeakerRepository());
     container.Inject(typeof(ISessionRepository), new SessionRepository());
 }
开发者ID:bsatrom,项目名称:Faceplant,代码行数:6,代码来源:Global.asax.cs

示例7: StructureMapUniResolver

 public StructureMapUniResolver(IContainer container)
     : base(container)
 {
     this._container = container;
     container.Inject<IHttpControllerActivator>(this);
 }
开发者ID:devworker55,项目名称:SourceLab,代码行数:6,代码来源:StructureMapUniResolver.cs

示例8: IntializeContainerForImport

        protected virtual void IntializeContainerForImport(IContainer container, DataImporter dataImporter)
        {
            // Temporarily inject the current context (dataImporter) into the container
            var context = new DataImporterPackageReaderContext(dataImporter);
            container.Inject<IPackageReaderContext>(context);
            container.Inject<IContentTransferContext>(dataImporter);

            // Create a ContentMap object that will live over the current thread/request
            IContentMap contentMap = new ContentMap();
            container.Inject<IContentMap>(contentMap);
        }
开发者ID:nordseth,项目名称:ComposerMigration,代码行数:11,代码来源:ImportInitializationModule.cs

示例9: because

 protected override void because()
 {
     _container = IoC.CreateContainer();
     _container.Inject(A.Fake<ITaskieServiceLocator>());
 }
开发者ID:DarrellMozingo,项目名称:Taskie,代码行数:5,代码来源:IoCFixture.cs

示例10: MainForm

 public MainForm(IContainer container)
 {
     InitializeComponent();
     container.Inject<IEmployeeDetailView>(ViewEmployeeDetail);
 }
开发者ID:jheintz,项目名称:presentations-and-training,代码行数:5,代码来源:MainForm.cs


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