Example #1
0
        public void DiTreeDTOMarshalTest()
        {
            DiTreeDTO dtoStart = Misc.CreateDiTreeDTO();

            MemoryStream ms = new MemoryStream();

            using (TinkarOutput output = new TinkarOutput(ms))
            {
                dtoStart.Marshal(output);
            }

            ms.Position = 0;
            using (TinkarInput input = new TinkarInput(ms))
            {
                DiTreeDTO dtoRead = DiTreeDTO.Make(input);
                Assert.True(dtoStart.CompareTo(dtoRead) == 0);
            }
        }
Example #2
0
        /// <summary>
        /// Read an array or Object fields.
        /// </summary>
        /// <returns>Object[].</returns>
        public Object GetField()
        {
            FieldDataType token;

            try
            {
                token = (FieldDataType)this.reader.ReadByte();
            }
            catch
            {
                return(null);
            }

            switch (token)
            {
            case FieldDataType.ConceptChronologyType:
                return(ConceptChronologyDTO.Make(this));

            case FieldDataType.PatternChronologyType:
                return(PatternChronologyDTO.Make(this));

            case FieldDataType.SemanticChronologyType:
                return(SemanticChronologyDTO.Make(this));

            case FieldDataType.ConceptVersionType:
                throw new NotImplementedException();

            case FieldDataType.PatternVersionType:
                throw new NotImplementedException();

            case FieldDataType.SemanticVersionType:
                throw new NotImplementedException();

            case FieldDataType.StampType:
                throw new NotImplementedException();

            case FieldDataType.ConceptType:
                return(ConceptDTO.Make(this));

            case FieldDataType.PatternType:
                return(PatternDTO.Make(this));

            case FieldDataType.SemanticType:
                return(SemanticDTO.Make(this));

            case FieldDataType.DiTreeType:
                return(DiTreeDTO.Make(this));

            case FieldDataType.DiGraphType:
                return(DiGraphDTO.Make(this));

            case FieldDataType.VertexType:
                throw new NotImplementedException();

            case FieldDataType.ComponentIdList:
                return(this.GetPublicIdList());

            case FieldDataType.ComponentIdSet:
                return(this.GetPublicIdSet());

            case FieldDataType.PlanarPoint:
                return(new PlanarPointDTO(this.GetInt32(), this.GetInt32()));

            case FieldDataType.SpatialPoint:
                return(new SpatialPointDTO(this.GetInt32(), this.GetInt32(), this.GetInt32()));

            case FieldDataType.StringType:
                return(this.GetUTF());

            case FieldDataType.IntegerType:
                return(this.GetInt32());

            case FieldDataType.FloatType:
                return(this.GetSingle());

            case FieldDataType.BooleanType:
                return(this.GetBoolean());

            case FieldDataType.ByteArrayType:
                return(this.GetByteArray());

            case FieldDataType.ObjectArrayType:
                return(this.GetObjects().ToArray());

            case FieldDataType.InstantType:
                return(this.GetInstant());

            default:
                throw new NotImplementedException($"FieldDataType {token} not known");
            }
        }