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


C# IContainer.GetInstance方法代码示例

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


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

示例1: Start

		public virtual void Start(IContainer container)
		{
			ErrorLog = container.GetInstance<IErrorLog>();
			IsRunning = true;
			TimerCallback callback = Execute;
			Timer = new Timer(callback, this, Interval, Interval);
		}
开发者ID:andyliyuze,项目名称:POPForums,代码行数:7,代码来源:ApplicationServiceBase.cs

示例2: Run

        public static void Run(IContainer settingsContainer)
        {
            var connectionString = settingsContainer.GetInstance<string>("DefaultConnection");

            Announcer announcer = new TextWriterAnnouncer(s => System.Diagnostics.Debug.WriteLine(s));
            announcer.ShowSql = true;

            Assembly assembly = typeof(CreateTableEstacionamento).Assembly;

            IRunnerContext migrationContext = new RunnerContext(announcer);

            var options = new ProcessorOptions
            {
                PreviewOnly = false,  // set to true to see the SQL
                Timeout = 60
            };

            try
            {
                var factory = settingsContainer.GetInstance<MigrationProcessorFactory>(); //new FluentMigrator.Runner.Processors.SQLite.SQLiteProcessorFactory();
                var processor = factory.Create(connectionString, announcer, options);

                var runner = new MigrationRunner(assembly, migrationContext, processor);
                runner.MigrateUp(true);
            }
            catch (Exception ex)
            {
                throw new InvalidOperationException("connectionString: " + connectionString, ex);
            }
        }
开发者ID:marcosli,项目名称:multi-vagas,代码行数:30,代码来源:MigrationsRunner.cs

示例3: Start

		public override void Start(IContainer container)
		{
			_searchService = container.GetInstance<ISearchService>();
			_settingsManager = container.GetInstance<ISettingsManager>();
			_postService = container.GetInstance<IPostService>();
			base.Start(container);
		}
开发者ID:andyliyuze,项目名称:POPForums,代码行数:7,代码来源:SearchIndexApplicationService.cs

示例4: MockedFubuRequestContext

 public MockedFubuRequestContext(IContainer container)
     : base(
         new StructureMapServiceLocator(container), container.GetInstance<IHttpRequest>(), container.GetInstance<IFubuRequest>(),
         container.GetInstance<IOutputWriter>(), new RecordingLogger())
 {
     
 }
开发者ID:,项目名称:,代码行数:7,代码来源:

示例5: LoadAppropriateStoreRegistry

 public static void LoadAppropriateStoreRegistry(IContainer initContainer)
 {
     var store = initContainer.GetInstance<IRRConfiguration>().ContentStore;
     if (store == Configuration.Store.SqlServerStore)
     {
         var sqlAssembly = Assembly.Load("RequestReduce.SqlServer");
         initContainer.Configure(x =>
                                     {
                                         x.For(sqlAssembly.GetType("RequestReduce.SqlServer.IFileRepository"))
                                             .Use(
                                                 sqlAssembly.GetType(
                                                     "RequestReduce.SqlServer.FileRepository"));
                                         var diskStore =
                                             new ConfiguredInstance(
                                                 sqlAssembly.GetType("RequestReduce.SqlServer.SqlServerStore"));
                                         var diskCache =
                                             new ConfiguredInstance(
                                                 sqlAssembly.GetType("RequestReduce.SqlServer.DbDiskCache"));
                                         x.For<LocalDiskStore>().Singleton()
                                             .Use(diskCache);
                                         diskStore.CtorDependency<LocalDiskStore>("fileStore").Is(
                                             initContainer.GetInstance<LocalDiskStore>());
                                         diskStore.CtorDependency<IUriBuilder>("uriBuilder").Is(
                                             initContainer.GetInstance<IUriBuilder>());
                                         diskStore.CtorDependency<IReductionRepository>("reductionRepository").Is(
                                             initContainer.GetInstance<IReductionRepository>());
                                         x.For<IStore>().LifecycleIs(new RRHybridLifecycle())
                                             .Use(diskStore);
                                     });
     }
     else
         initContainer.Configure(x => x.AddRegistry<RRLocalStoreRegistry>());
 }
开发者ID:andrewdavey,项目名称:RequestReduce,代码行数:33,代码来源:RRContainer.cs

示例6: Start

		public override void Start(IContainer container)
		{
			_settingsManager = container.GetInstance<ISettingsManager>();
			_smtpWrapper = container.GetInstance<ISmtpWrapper>();
			_queuedEmailRepository = container.GetInstance<IQueuedEmailMessageRepository>();
			base.Start(container);
		}
开发者ID:andyliyuze,项目名称:POPForums,代码行数:7,代码来源:EmailApplicationService.cs

示例7: MainWindow

 public MainWindow(IContainer container)
 {
     InitializeComponent();
     _container = container;
     _episodeSearcher = _container.GetInstance<IEpisodeSearcher>();
     _dbReader = _container.GetInstance<IDatabaseReader>();
     Loaded += MainWindow_Loaded;
 }
开发者ID:wettsten,项目名称:EpiFlow,代码行数:8,代码来源:MainWindow.xaml.cs

示例8: SetUp

        public void SetUp()
        {
            _container = IoC.Initialize();
               var mock = IoC.MockStore;
               mock.Setup(s => s.GetItems()).Returns(Enumerable.Empty<Commitment>());

               _repo = _container.GetInstance<IRepository<Commitment>>();
               _taskListModel = _container.GetInstance<ITaskListModel>();
        }
开发者ID:GeoffBurns,项目名称:ASP-MVC3-razor-Sample,代码行数:9,代码来源:When_TaskList_is_Empty.cs

示例9: SetUp

        public void SetUp(DateTime date)
        {
            _container = IoC.Initialize();
            var mock = IoC.MockStore;
            mock.Setup(s => s.GetItems()).Returns(new[] { new Commitment { DueDate = date } });

            _taskListModel = _container.GetInstance<ITaskListModel>();
            _repo = _container.GetInstance<IRepository<Commitment>>();
        }
开发者ID:GeoffBurns,项目名称:ASP-MVC3-razor-Sample,代码行数:9,代码来源:When_TaskList_Contains_Task.cs

示例10: ConfigHandler

        /// <summary>
        /// Constructs an instance of FileResourceHandler
        /// </summary>
        /// <param name="request">Request object injected by OpenRasta</param>
        /// <param name="response">Response object injected by OpenRasta</param>
        /// <param name="container">StructureMap container to use with the handler</param>
        public ConfigHandler(IRequest request, IResponse response, IContainer container)
        {
            _request = request;
            _response = response;
            _container = container;

            _repository = _container.GetInstance<IRepository<IJsonEntity<ConfigRoot>>>();
            _log = _container.GetInstance<ILogger>();
        }
开发者ID:killthrush,项目名称:Habitat.Server,代码行数:15,代码来源:ConfigHandler.cs

示例11: SetUp

        public override void SetUp()
        {
            _idToName.ClearAll();

            _container = Container.For<DevelopmentModeRegistry>();
            _session = _container.GetInstance<IDocumentStore>().OpenSession();
            _container.GetInstance<IDocumentStore>().Advanced.Clean.CompletelyRemoveAll();

        }
开发者ID:danielmarbach,项目名称:marten,代码行数:9,代码来源:OrderingFixture.cs

示例12: BeforeAll

        public void BeforeAll()
        {
            _container = bootstrap_ioc.getContainer(c => { });
            _cut = _container.GetInstance<UserImpersonationService>();

            _settings = _container.GetInstance<DovetailDatabaseSettings>();
            _settings.IsImpersonationEnabled = true;

            beforeAll();
        }
开发者ID:modulexcite,项目名称:dovetail-bootstrap,代码行数:10,代码来源:user_impersonation_service.cs

示例13: Configure

        public static Form Configure()
        {
            Container = new Container();
            Container.Configure(c => c.AddRegistry<DefaultRegistry>());

            var mainForm = Container.GetInstance<AppShell>();
            Container.GetInstance<CataloguePresenter>();

            return mainForm;
        }
开发者ID:nyxiscoo1,项目名称:DipDemo,代码行数:10,代码来源:Bootstrapper.cs

示例14: Singleton

 public void Singleton()
 {
     Container = new Container(x => x.For<ICounter>().Singleton().Use<Counter>());
     var c1 = Container.GetInstance<ICounter>();
     c1.Inc();
     Assert.That(c1.Count, Is.EqualTo(1));
     var c2 = Container.GetInstance<ICounter>();
     c2.Inc();
     Assert.That(c2.Count, Is.EqualTo(2));
 }
开发者ID:recr0ns,项目名称:IoCTesting,代码行数:10,代码来源:IoCTesting.cs

示例15: SystemViewRegistry

		public SystemViewRegistry(IContainer container)
		{
			IConfiguration configuration = container.GetInstance<IConfiguration>();

			RegisterControlBus(configuration.SystemViewControlUri, x => { });

			RegisterServiceBus(configuration.SystemViewDataUri, x =>
				{
					x.SetConcurrentConsumerLimit(1);
					x.UseControlBus(container.GetInstance<IControlBus>());

					ConfigureSubscriptionClient(configuration.SubscriptionServiceUri, x);
				});
		}
开发者ID:KevM,项目名称:MassTransit,代码行数:14,代码来源:SystemViewRegistry.cs


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