本文整理汇总了C#中Property.GetUnderlyingType方法的典型用法代码示例。如果您正苦于以下问题:C# Property.GetUnderlyingType方法的具体用法?C# Property.GetUnderlyingType怎么用?C# Property.GetUnderlyingType使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Property
的用法示例。
在下文中一共展示了Property.GetUnderlyingType方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: JsonToProperty
public static Property JsonToProperty(string jsonString)
{
var json = JsonObject.Parse(jsonString);
var property = new Property()
{
Description = json.Get("Description"),
Href = json.Get<Uri>("Href"),
Type = json.Get("Type"),
Name = json.Get("Name"),
HrefItems = json.Get<Uri>("HrefItems"),
ItemsDisplayedCount = json.Get<int?>("ItemsDisplayedCount"),
ItemsTotalCount = json.Get<int?>("ItemsTotalCount")
};
if (json.ContainsKey("UserModifiedBy"))
{
property.UserModifiedBy = JsonSerializer.DeserializeFromString<UserCompact>(json.Child("UserModifiedBy"));
}
if (json.ContainsKey("ApplicationModifiedBy"))
{
property.ApplicationModifiedBy = JsonSerializer.DeserializeFromString<ApplicationCompact>(json.Child("ApplicationModifiedBy"));
}
if (json.ContainsKey("DateModified"))
{
property.DateModified = JsonSerializer.DeserializeFromString<DateTime>(json.Get("DateModified"));
}
var simpleType = property.GetUnderlyingType();
if (json.ContainsKey("Content"))
{
switch (simpleType)
{
case PropertyTypes.STRING:
property.Content = new PropertyContentLiteral(property.Type, json.Get("Content"));
break;
case PropertyTypes.MAP:
property.Content = JsonSerializer.DeserializeFromString<PropertyContentMap>(json.Child("Content"));
break;
default:
property.Content = DeserializePropertyReference(simpleType, json.Child("Content"));
break;
}
}
if (json.ContainsKey("Items"))
{
switch (simpleType)
{
case PropertyTypes.STRING:
property.Items = json.Get<string[]>("Items").Select(i => new PropertyContentLiteral(simpleType, i)).ToArray();
break;
case PropertyTypes.MAP:
property.Items = JsonSerializer.DeserializeFromString<PropertyContentMap[]>(json.Child("Items"));
break;
default:
property.Items = json.ArrayObjects("Items").Select(itemj => DeserializePropertyReference(simpleType, itemj.ToJson())).Where(x => x != null).ToArray();
break;
}
}
return property;
}