本文整理汇总了C#中SimpleContainer.Handler方法的典型用法代码示例。如果您正苦于以下问题:C# SimpleContainer.Handler方法的具体用法?C# SimpleContainer.Handler怎么用?C# SimpleContainer.Handler使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SimpleContainer
的用法示例。
在下文中一共展示了SimpleContainer.Handler方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Configure
protected override void Configure()
{
container = new SimpleContainer();
container.Singleton<IWindowManager, MetroWindowManager>();
container.Singleton<IEventAggregator, EventAggregator>();
var baseExperienceData = new ExperienceData() { DisplayName = "Base Experience" };
var classExperienceData = new ExperienceData() { DisplayName = "Class Experience" };
IExperienceControl[] baseExperienceControls = GetExperienceControls(baseExperienceData, classExperienceData);
ExperienceContainer experienceContainer = new ExperienceContainer(baseExperienceData, classExperienceData, baseExperienceControls);
container.Handler<ShellViewModel>(simpleContainer =>
new ShellViewModel(
container.GetInstance<SettingsViewModel>(),
experienceContainer,
new ExpCardCalculatorViewModel(experienceContainer),
container.GetInstance<IWindowManager>()));
// TODO - refactor settings view model to just take a collection of menuitems
container.Handler<SettingsViewModel>(simpleContainer => new SettingsViewModel(baseExperienceControls));
}
示例2: HandlerTest
public void HandlerTest()
{
SimpleContainer sc = new SimpleContainer();
ITest1 t1 = null;
sc.Handler<ITest1>((i) =>
{
Assert.AreEqual(sc, i);
t1 = new Test1();
return t1;
});
var result1 = sc.GetInstance<ITest1>();
Assert.IsNotNull(t1);
Assert.IsNotNull(result1);
Assert.AreEqual(t1, result1);
Test2 t2 = null;
sc.Handler<ITest2, Test2>(i =>
{
Assert.AreEqual(sc, i);
t2 = new Test2();
return t2;
});
var result2 = sc.GetInstance<ITest2>();
Assert.IsNotNull(t2);
Assert.IsNotNull(result2);
Assert.AreEqual(t2, result2);
result2 = sc.GetInstance<Test2>();
Assert.IsNotNull(result2);
Assert.AreEqual(t2, result2);
}