/// <summary> /// Converts extension data from a deserialised JSON object into usable data. /// </summary> /// <param name="data">An ExtensionDataObject containing the extension data.</param> /// <returns>A JsonExtensionDataItemCollection containing the results.</returns> internal static JsonExtensionDataItemCollection ConvertExtensionData(ExtensionDataObject data) { JsonExtensionDataItemCollection ReturnValue; // Defaults ReturnValue = new JsonExtensionDataItemCollection(); ReturnValue = UnpackExtensionDataMembers(data); return(ReturnValue); }
private static JsonExtensionDataItemCollection UnpackExtensionDataMembers(object item) { PropertyInfo MemberProperty; JsonExtensionDataItemCollection ReturnValue; // Defaults ReturnValue = new JsonExtensionDataItemCollection(); // Get member data MemberProperty = FindProperty(item, "Members"); if (MemberProperty != null) { object MembersValue; MembersValue = MemberProperty.GetValue(item); if (MembersValue != null && MembersValue is IList) { IList MemberList; // Go through each item MemberList = (IList)MembersValue; foreach (object Item in MemberList) { JsonExtensionDataItem UnpackedItem; UnpackedItem = UnpackExtensionDataMember(Item); if (UnpackedItem != null) { ReturnValue.Add(UnpackedItem); } } } } return(ReturnValue); }
/// <summary> /// Creates a new instance of the class with the specified parameters. /// </summary> /// <param name="name">A string containing the name of the item.</param> /// <param name="items">A JsonExtensionDataItemCollection containing the items belonging to this item.</param> internal JsonExtensionDataItem(string name, JsonExtensionDataItemCollection items) : this(name, null, null) { Items = items; }