コード例 #1
0
        /// <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);
        }
コード例 #2
0
ファイル: TinkarInput.cs プロジェクト: HL7/tinkar-cs
        /// <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);
        }
コード例 #3
0
        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);
            }
        }
コード例 #4
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);
            }
        }