本文整理汇总了C#中IocContainer.GetValue方法的典型用法代码示例。如果您正苦于以下问题:C# IocContainer.GetValue方法的具体用法?C# IocContainer.GetValue怎么用?C# IocContainer.GetValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IocContainer
的用法示例。
在下文中一共展示了IocContainer.GetValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TypeValue_Test2
public void TypeValue_Test2()
{
var type = typeof(IValueService);
var container = new IocContainer();
var childContainer = new IocContainer(container);
container.AddValue(type, "A", 15);
Assert.Equal(15, childContainer.GetValue(type, "A"));
int index = 0;
container.AddValue(type, "B", lmp => ++index);
Assert.Equal(1, childContainer.GetValue(type, "B"));
Assert.Equal(2, childContainer.GetValue(type, "B"));
index = 0;
container.AddValue(type, "C", lmp => ++index, true);
Assert.Equal(1, childContainer.GetValue(type, "C"));
Assert.Equal(1, childContainer.GetValue(type, "C"));
Assert.True(childContainer.ContainsValue(type, "A", true));
container.RemoveValue(type, "A", true);
Assert.False(childContainer.ContainsValue(type, "A", true));
index = 0;
container.AddValue(type, "D", lmp => ++index);
Assert.Equal(1, childContainer.GetValue(type, "D"));
Assert.Equal(2, container.GetValue(type, "D"));
}
示例2: Value_Test1
public void Value_Test1()
{
var container = new IocContainer();
container.AddValue("A", 15);
Assert.Equal(15, container.GetValue("A"));
int index = 0;
container.AddValue("B", lmp => ++index);
Assert.Equal(1, container.GetValue("B"));
Assert.Equal(2, container.GetValue("B"));
index = 0;
container.AddValue("C", lmp => ++index, true);
Assert.Equal(1, container.GetValue("C"));
Assert.Equal(1, container.GetValue("C"));
Assert.True(container.ContainsValue("A"));
container.RemoveValue("A");
Assert.False(container.ContainsValue("A"));
}