/// <summary> /// Read FieldDefinitionDTO values from the named child property. /// </summary> /// <param name="jObj">JSON parent container.</param> /// <param name="fieldName">JSON child field name.</param> /// <returns>Field definition values.</returns> public static IEnumerable <FieldDefinitionDTO> AsFieldDefinitionList(this JObject jObj, String fieldName) { List <FieldDefinitionDTO> retVal = new List <FieldDefinitionDTO>(); JArray items = jObj.ReadToken <JArray>(fieldName); foreach (JObject item in items.Values <JObject>()) { retVal.Add(FieldDefinitionDTO.Make(item)); } return(retVal); }
/// <summary> /// Read an array or FieldDefinitionDTO items. /// </summary> /// <returns>FieldDefinitionDTO[].</returns> public FieldDefinitionDTO[] GetFieldDefinitionList() { Int32 length = this.GetInt32(); FieldDefinitionDTO[] retVal = new FieldDefinitionDTO[length]; for (Int32 i = 0; i < length; i++) { retVal[i] = FieldDefinitionDTO.Make(this); } return(retVal); }
public void FieldDefinitionDTOJsonMarshal() { FieldDefinitionDTO dtoStart = Misc.CreateFieldDefinitionDTO; MemoryStream ms = new MemoryStream(); using (TinkarJsonOutput output = new TinkarJsonOutput(ms, true)) { dtoStart.Marshal(output); } ms.Dump(); ms.Position = 0; using (TinkarJsonInput input = new TinkarJsonInput(ms)) { FieldDefinitionDTO dtoEnd = FieldDefinitionDTO.Make(input.ReadJsonObject()); Assert.True(dtoStart.CompareTo(dtoEnd) == 0); } }
public void FieldDefinitionDTOMarshalTest() { FieldDefinitionDTO dtoStart = new FieldDefinitionDTO( Misc.PublicIdG, Misc.PublicIdH, Misc.PublicIdI ); MemoryStream ms = new MemoryStream(); using (TinkarOutput output = new TinkarOutput(ms)) { dtoStart.Marshal(output); } ms.Position = 0; using (TinkarInput input = new TinkarInput(ms)) { FieldDefinitionDTO dtoRead = FieldDefinitionDTO.Make(input); Assert.True(dtoStart.CompareTo(dtoRead) == 0); } }