本文整理汇总了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));
}));
}
示例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;
}
示例3: StructureMapResolver
public StructureMapResolver(IContainer container)
: base(container)
{
if (container == null)
throw new ArgumentNullException("container");
_container = container;
_container.Inject(typeof(IHttpControllerActivator), this);
}
示例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();
}
示例5: Register
public override void Register(IContainer container, List<SiteRoute> routes, ViewEngineCollection viewEngines, ModelBinderDictionary modelBinders, ICollection<Asset> globalAssets)
{
/*
<svc:include name="LiteralWidget">
<div class="widget settings area">
<h3>Windows Live Writer Workaround</h3>
<a href="/WLWWorkaround/WLWWorkaround">Activate/Disable</a>
</div>
</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
});
}
示例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());
}
示例7: StructureMapUniResolver
public StructureMapUniResolver(IContainer container)
: base(container)
{
this._container = container;
container.Inject<IHttpControllerActivator>(this);
}
示例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);
}
示例9: because
protected override void because()
{
_container = IoC.CreateContainer();
_container.Inject(A.Fake<ITaskieServiceLocator>());
}
示例10: MainForm
public MainForm(IContainer container)
{
InitializeComponent();
container.Inject<IEmployeeDetailView>(ViewEmployeeDetail);
}