本文整理汇总了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);
}
示例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);
}
}
示例3: Start
public override void Start(IContainer container)
{
_searchService = container.GetInstance<ISearchService>();
_settingsManager = container.GetInstance<ISettingsManager>();
_postService = container.GetInstance<IPostService>();
base.Start(container);
}
示例4: MockedFubuRequestContext
public MockedFubuRequestContext(IContainer container)
: base(
new StructureMapServiceLocator(container), container.GetInstance<IHttpRequest>(), container.GetInstance<IFubuRequest>(),
container.GetInstance<IOutputWriter>(), new RecordingLogger())
{
}
示例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>());
}
示例6: Start
public override void Start(IContainer container)
{
_settingsManager = container.GetInstance<ISettingsManager>();
_smtpWrapper = container.GetInstance<ISmtpWrapper>();
_queuedEmailRepository = container.GetInstance<IQueuedEmailMessageRepository>();
base.Start(container);
}
示例7: MainWindow
public MainWindow(IContainer container)
{
InitializeComponent();
_container = container;
_episodeSearcher = _container.GetInstance<IEpisodeSearcher>();
_dbReader = _container.GetInstance<IDatabaseReader>();
Loaded += MainWindow_Loaded;
}
示例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>();
}
示例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>>();
}
示例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>();
}
示例11: SetUp
public override void SetUp()
{
_idToName.ClearAll();
_container = Container.For<DevelopmentModeRegistry>();
_session = _container.GetInstance<IDocumentStore>().OpenSession();
_container.GetInstance<IDocumentStore>().Advanced.Clean.CompletelyRemoveAll();
}
示例12: BeforeAll
public void BeforeAll()
{
_container = bootstrap_ioc.getContainer(c => { });
_cut = _container.GetInstance<UserImpersonationService>();
_settings = _container.GetInstance<DovetailDatabaseSettings>();
_settings.IsImpersonationEnabled = true;
beforeAll();
}
示例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;
}
示例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));
}
示例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);
});
}