/// <summary> /// For multi-value properties of type 'run[]', returns property items as RunCompact[] /// </summary> public static RunCompact[] ToRunsArray(this PropertyItemsResourceList propertyItemsResourceList) { if ((propertyItemsResourceList.Type ?? string.Empty) != PropertyTypes.RUN + PropertyTypes.LIST_SUFFIX) { return(null); } return(propertyItemsResourceList.ToResourceArray <RunCompact>()); }
/// <summary> /// For multi-value properties of type 'project[]', returns property items as ProjectCompact[] /// </summary> public static ProjectCompact[] ToProjectArray(this PropertyItemsResourceList propertyItemsResourceList) { if ((propertyItemsResourceList.Type ?? string.Empty) != PropertyTypes.PROJECT + PropertyTypes.LIST_SUFFIX) { return(null); } return(propertyItemsResourceList.ToResourceArray <ProjectCompact>()); }
/// <summary> /// For multi-value properties of type 'appsession[]', returns property items as AppSessionCompact[] /// </summary> public static AppSessionCompact[] ToAppSessionArray(this PropertyItemsResourceList propertyItemsResourceList) { if ((propertyItemsResourceList.Type ?? string.Empty) != PropertyTypes.APPSESSION + PropertyTypes.LIST_SUFFIX) { return(null); } return(propertyItemsResourceList.ToResourceArray <AppSessionCompact>()); }
/// <summary> /// For multi-value properties of type 'appresult[]', returns property items as AppResultCompact[] /// </summary> public static AppResultCompact[] ToAppResultArray(this PropertyItemsResourceList propertyItemsResourceList) { if ((propertyItemsResourceList.Type ?? string.Empty) != PropertyTypes.APPRESULT + PropertyTypes.LIST_SUFFIX) { return(null); } return(propertyItemsResourceList.ToResourceArray <AppResultCompact>()); }
/// <summary> /// For multi-value properties of type 'sample[]', returns property items as SampleCompact[] /// </summary> public static SampleCompact[] ToSampleArray(this PropertyItemsResourceList propertyItemsResourceList) { if ((propertyItemsResourceList.Type ?? string.Empty) != PropertyTypes.SAMPLE + PropertyTypes.LIST_SUFFIX) { return(null); } return(propertyItemsResourceList.ToResourceArray <SampleCompact>()); }
/// <summary> /// For multi-value properties containing resource references, returns property items referencing the given type as an array /// </summary> public static TResourceType[] ToResourceArray <TResourceType>(this PropertyItemsResourceList propertyItemsResourceList) where TResourceType : class, IPropertyContent { if (propertyItemsResourceList.Items != null) { return(propertyItemsResourceList.Items.Select(i => i.Content.ToResource <TResourceType>()).Where(i => i != null).ToArray()); } return(null); }
public static PropertyItemsResourceList JsonToPropertyItemsResourceList(string jsonString) { var json = JsonObject.Parse(jsonString); var ret = new PropertyItemsResourceList() { DisplayedCount = json["DisplayedCount"].To <int?>(), TotalCount = json["TotalCount"].To <int?>(), Limit = json["Limit"].To <int>(), Offset = json["Offset"].To <int>(), SortBy = json["SortBy"].To <PropertyItemsSortByParameters?>(), SortDir = json["SortDir"].To <SortDirection?>() }; ret.Type = json["Type"]; var simpleType = ret.Type.Replace(PropertyTypes.LIST_SUFFIX, String.Empty); switch (simpleType) { case PropertyTypes.STRING: ret.Items = json.ArrayObjects("Items") .Select( itemj => new PropertyItem(itemj["Id"], new PropertyContentLiteral(simpleType, itemj["Content"]))) .ToArray(); break; case PropertyTypes.MAP: ret.Items = json.ArrayObjects("Items").Select(itemj => new PropertyItem(itemj["Id"], JsonSerializer.DeserializeFromString <PropertyContentMap>(itemj.Child("Content")))) .ToArray(); break; ; default: ret.Items = json.ArrayObjects("Items") .Select( itemj => new PropertyItem() { Id = itemj["Id"], Content = DeserializePropertyReference(simpleType, itemj.Child("Content")) }) .ToArray(); break; } return(ret); }
public static PropertyItemsResourceList JsonToPropertyItemsResourceList(string jsonString) { var json = JsonObject.Parse(jsonString); var ret = new PropertyItemsResourceList() { DisplayedCount = json["DisplayedCount"].To<int?>(), TotalCount = json["TotalCount"].To<int?>(), Limit = json["Limit"].To<int>(), Offset = json["Offset"].To<int>(), SortBy = json["SortBy"].To<PropertyItemsSortByParameters?>(), SortDir = json["SortDir"].To<SortDirection?>() }; ret.Type = json["Type"]; var simpleType = ret.Type.Replace(PropertyTypes.LIST_SUFFIX, String.Empty); switch (simpleType) { case PropertyTypes.STRING: ret.Items = json.ArrayObjects("Items") .Select( itemj => new PropertyItem(itemj["Id"], new PropertyContentLiteral(simpleType, itemj["Content"]))) .ToArray(); break; case PropertyTypes.MAP: ret.Items = json.ArrayObjects("Items").Select(itemj => new PropertyItem(itemj["Id"], JsonSerializer.DeserializeFromString<PropertyContentMap>(itemj.Child("Content")))) .ToArray(); break; ; default: ret.Items = json.ArrayObjects("Items") .Select( itemj => new PropertyItem() { Id = itemj["Id"], Content = DeserializePropertyReference(simpleType, itemj.Child("Content")) }) .ToArray(); break; } return ret; }