本文整理汇总了C#中IdmResource.GetAttr方法的典型用法代码示例。如果您正苦于以下问题:C# IdmResource.GetAttr方法的具体用法?C# IdmResource.GetAttr怎么用?C# IdmResource.GetAttr使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IdmResource
的用法示例。
在下文中一共展示了IdmResource.GetAttr方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: It_can_GetAttributeAsComplexObject_when_the_attribute_has_a_refId_value_and_the_backing_field_is_null
public void It_can_GetAttributeAsComplexObject_when_the_attribute_has_a_refId_value_and_the_backing_field_is_null()
{
var creatorObjectID = Guid.NewGuid().ToString("D");
IdmResource subResource = null;
var it = new IdmResource { Attributes = new List<IdmAttribute> { new IdmAttribute { Name = "Creator", Value = creatorObjectID } } };
// ReSharper disable once ExpressionIsAlwaysNull
it.GetAttr("Creator", subResource);
Assert.AreEqual(creatorObjectID, it.Creator.ObjectID);
}
示例2: It_can_GetAttributeAsComplexObject_when_the_attribute_has_a_refId_value_and_the_backing_field_ObjetID_matches_the_value_in_the_attribute
public void It_can_GetAttributeAsComplexObject_when_the_attribute_has_a_refId_value_and_the_backing_field_ObjetID_matches_the_value_in_the_attribute()
{
var freshCreatorObjectID = Guid.NewGuid().ToString("D");
var creator = new IdmResource
{
CreatedTime = DateTime.Now,
Description = "Test creator",
DisplayName = "Joe User",
ExpirationTime = DateTime.Now + TimeSpan.FromDays(1),
MVObjectID = Guid.NewGuid().ToString("D"),
ObjectID = freshCreatorObjectID,
ObjectType = "Person",
ResourceTime = DateTime.Now
};
var it = new IdmResource { Attributes = new List<IdmAttribute> { new IdmAttribute { Name = "Creator", Value = freshCreatorObjectID } } };
var result = it.GetAttr("Creator", creator);
Assert.AreEqual(freshCreatorObjectID, it.Creator.ObjectID);
Assert.AreEqual("Joe User", result.DisplayName);
}
示例3: BuildAttribute
private static void BuildAttribute(XmlNode attribute, IdmResource resource)
{
string name = attribute.LocalName;
string val = attribute.InnerText;
if (val.StartsWith("urn:uuid:"))
val = val.Substring(9);
var attr = resource.GetAttr(name);
if (attr != null)
attr.Values.Add(val);
else
resource.Attributes.Add(new IdmAttribute { Name = name, Value = val });
}
示例4: It_should_return_null_for_empty_attributes
public void It_should_return_null_for_empty_attributes()
{
var it = new IdmResource();
Assert.IsNull(it.GetAttr("foo"));
Assert.IsNull(it.GetAttrValue("foo"));
Assert.IsNull(it.GetAttrValues("foo"));
}
示例5: It_can_SettAttrValue_nullable_null_value_and_come_back_as_null_as_either_Value_or_ToInt
public void It_can_SettAttrValue_nullable_null_value_and_come_back_as_null_as_either_Value_or_ToInt()
{
var it = new IdmResource();
it.SetAttrValue("foo", null);
var result1 = it.GetAttrValue("foo");
var result2 = it.GetAttr("foo").ToInteger();
var result3 = it.GetAttr("foo").ToDateTime();
var result4 = it.GetAttr("foo").ToBinary();
var result5 = it.GetAttr("foo").ToBool();
Assert.IsNull(result1);
Assert.IsNull(result2);
Assert.IsNull(result3);
Assert.IsNull(result4);
Assert.IsNull(result5);
}
示例6: It_can_GettAttr_that_then_allows_modification_of_the_attr
public void It_can_GettAttr_that_then_allows_modification_of_the_attr()
{
var it = new IdmResource
{
Attributes =
new List<IdmAttribute> { new IdmAttribute { Name = "foo", Values = new List<string> { "foo", "bar" } } }
};
var attr = it.GetAttr("foo");
attr.Values.Add("bat");
var result = it.GetAttrValues("foo");
Assert.AreEqual("foo", result[0]);
Assert.AreEqual("bar", result[1]);
Assert.AreEqual("bat", result[2]);
}