本文整理汇总了C#中PropertyBag.GetPropertyValue方法的典型用法代码示例。如果您正苦于以下问题:C# PropertyBag.GetPropertyValue方法的具体用法?C# PropertyBag.GetPropertyValue怎么用?C# PropertyBag.GetPropertyValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PropertyBag
的用法示例。
在下文中一共展示了PropertyBag.GetPropertyValue方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ThrowsArgumentExceptionForInvalidPropertyName
public void ThrowsArgumentExceptionForInvalidPropertyName()
{
var propertyBag = new PropertyBag();
ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => propertyBag.GetPropertyValue<object>(null));
ExceptionTester.CallMethodAndExpectException<ArgumentException>(() => propertyBag.GetPropertyValue<object>(string.Empty));
}
示例2: ReturnsDefaultValueForNonRegisteredProperty
public void ReturnsDefaultValueForNonRegisteredProperty()
{
var propertyBag = new PropertyBag();
Assert.AreEqual(null, propertyBag.GetPropertyValue<string>("StringProperty"));
Assert.AreEqual(0, propertyBag.GetPropertyValue<int>("IntProperty"));
}
示例3: ReturnsRightPropertyValue
public void ReturnsRightPropertyValue()
{
var propertyBag = new PropertyBag();
propertyBag.SetPropertyValue("StringProperty", "test");
propertyBag.SetPropertyValue("IntProperty", 1);
Assert.AreEqual("test", propertyBag.GetPropertyValue<string>("StringProperty"));
Assert.AreEqual(1, propertyBag.GetPropertyValue<int>("IntProperty"));
}
示例4: SetsPropertyCorrectly
public void SetsPropertyCorrectly()
{
var propertyBag = new PropertyBag();
propertyBag.SetPropertyValue("StringProperty", "A");
Assert.AreEqual("A", propertyBag.GetPropertyValue<string>("StringProperty"));
propertyBag.SetPropertyValue("StringProperty", "B");
Assert.AreEqual("B", propertyBag.GetPropertyValue<string>("StringProperty"));
}