Exemple #1
0
        public Int32 CompareTo(object o)
        {
            IPublicId other = o as IPublicId;

            if (other == null)
            {
                return(this.GetType().FullName.CompareTo(o.GetType().FullName));
            }

            Int32 cmpVal = this.UuidCount.CompareTo(other.UuidCount);

            if (cmpVal != 0)
            {
                return(cmpVal);
            }
            for (Int32 i = 0; i < this.UuidCount; i++)
            {
                cmpVal = this[i].CompareTo(other[i]);
                if (cmpVal != 0)
                {
                    return(cmpVal);
                }
            }
            return(0);
        }
Exemple #2
0
        /// <summary>
        /// Read an array or ConceptVersionDTO items.
        /// </summary>
        /// <param name="publicId">Public id (component ids).</param>
        /// <returns>ConceptVersionDTO[].</returns>
        public ConceptVersionDTO[] GetConceptVersionList(IPublicId publicId)
        {
            Int32 length = this.GetInt32();

            ConceptVersionDTO[] retVal = new ConceptVersionDTO[length];
            for (Int32 i = 0; i < length; i++)
            {
                retVal[i] = ConceptVersionDTO.Make(this, publicId);
            }
            return(retVal);
        }
Exemple #3
0
        /// <summary>
        /// Read PatternForSemanticVersionDTO values from the named child property.
        /// </summary>
        /// <param name="jObj">JSON parent container.</param>
        /// <param name = "publicId" > Public id(component ids).</param>
        /// <returns>Definition for semantic version values.</returns>
        public static IEnumerable <PatternVersionDTO> ReadPatternVersionList(
            this JObject jObj,
            IPublicId publicId)
        {
            List <PatternVersionDTO> retVal = new List <PatternVersionDTO>();
            JArray items = jObj.ReadToken <JArray>(ComponentFieldForJson.DEFINITION_VERSIONS);

            foreach (JObject item in items.Values <JObject>())
            {
                retVal.Add(PatternVersionDTO.Make(item, publicId));
            }
            return(retVal);
        }
Exemple #4
0
        public static PBPublicId ToPBPublicId(this IPublicId publicId)
        {
            //# Tested
            PBPublicId retval = new PBPublicId();

            ByteString[] tids = new ByteString[publicId.UuidCount];
            for (Int32 i = 0; i < publicId.UuidCount; i++)
            {
                tids[i] = publicId[i].ToByteString();
            }
            retval.Id.AddRange(tids);
            return(retval);
        }
Exemple #5
0
        /// <summary>
        /// Read an array or TypePatternVersionDTO items.
        /// </summary>
        /// <param name="publicId">Public id (component ids).</param>
        /// <returns>TypePatternVersionDTO[].</returns>
        public PatternVersionDTO[] GetPatternVersionList(IPublicId publicId)
        {
            Int32 length = this.GetInt32();

            PatternVersionDTO[] retVal = new PatternVersionDTO[length];

            // Generate array to avoid multiple enumerations of componentUuids.
            Guid[] componentUuidArr = publicId.AsUuidArray;
            for (Int32 i = 0; i < length; i++)
            {
                retVal[i] = PatternVersionDTO.Make(this, publicId);
            }
            return(retVal);
        }
Exemple #6
0
        /// <summary>
        /// Read ConceptVersionDTO values from the named child property.
        /// </summary>
        /// <param name="jObj">JSON parent container.</param>
        /// <param name = "fieldName" > JSON child field name</param>
        /// <param name = "publicId" > Public id(component ids).</param>
        /// <returns>Concept version values.</returns>
        public static IEnumerable <ConceptVersionDTO> AsConceptVersionList(
            this JObject jObj,
            String fieldName,
            IPublicId publicId)
        {
            List <ConceptVersionDTO> retVal = new List <ConceptVersionDTO>();

            JArray items = jObj.ReadToken <JArray>(fieldName);

            foreach (JObject item in items.Values <JObject>())
            {
                retVal.Add(ConceptVersionDTO.Make(item, publicId));
            }
            return(retVal);
        }
Exemple #7
0
        /// <summary>
        /// Read an array or SemanticVersionDTO items.
        /// </summary>
        /// <param name="publicId">Public id (component ids).</param>
        /// <returns>SemanticVersionDTO[].</returns>
        public SemanticVersionDTO[] ReadSemanticVersionList(
            IPublicId publicId)
        {
            Int32 length = this.GetInt32();

            SemanticVersionDTO[] retVal = new SemanticVersionDTO[length];
            for (Int32 i = 0; i < length; i++)
            {
                retVal[i] = SemanticVersionDTO.Make(
                    this,
                    publicId);
            }

            return(retVal);
        }
Exemple #8
0
        /// <summary>
        /// Read SemanticVersionDTO values from the named child property.
        /// </summary>
        /// <param name="jObj">JSON parent container.</param>
        /// <param name = "publicId" > Public id(component ids).</param>
        /// <param name = "fieldName" > Json child field name.</param>
        /// <param name="definitionForSemanticPublicId">Externally defined definition for semantic uuids.</param>
        /// <param name="referencedComponentPublicId">Externally defined referenced component uuids.</param>
        /// <returns>Semantic version values.</returns>
        public static IEnumerable <SemanticVersionDTO> ReadSemanticVersionList(
            this JObject jObj,
            String fieldName,
            IPublicId publicId,
            IPublicId definitionForSemanticPublicId,
            IPublicId referencedComponentPublicId)
        {
            List <SemanticVersionDTO> retVal = new List <SemanticVersionDTO>();

            JArray items = jObj.ReadToken <JArray>(fieldName);

            foreach (JObject item in items.Values <JObject>())
            {
                retVal.Add(SemanticVersionDTO.Make(item, publicId));
            }
            return(retVal);
        }
Exemple #9
0
        public Boolean IsEquivalent(Object o)
        {
            IPublicId other = o as IPublicId;

            if (other == null)
            {
                return(false);
            }

            Int32 thisIdIndex  = 0;
            Int32 otherIdIndex = 0;
            Int32 thisCount    = this.UuidCount;
            Int32 otherCount   = other.UuidCount;

            while (true)
            {
                Int32 cmpVal = this[thisIdIndex].CompareTo(other[otherIdIndex]);
                if (cmpVal < 0)
                {
                    if (++thisIdIndex >= thisCount)
                    {
                        return(false);
                    }
                }
                else if (cmpVal > 0)
                {
                    if (++otherIdIndex >= otherCount)
                    {
                        return(false);
                    }
                }
                else
                {
                    return(true);
                }
            }
        }
Exemple #10
0
 public static ConceptVersionDTO cv2(IPublicId publicId) => new ConceptVersionDTO(publicId, Misc.CreateStampDTO with {
Exemple #11
0
 /// <summary>
 /// Write property that is array of guids.
 /// </summary>
 /// <param name="propertyName">Name of json property to write.</param>
 /// <param name="publicId">PublicId to write.</param>
 public void Put(String propertyName, IPublicId publicId) => this.WriteUuids(propertyName, publicId.AsUuidArray);
Exemple #12
0
 /// <summary>
 /// Compare two PublicId instances and return true if each has the same
 /// Guid values.
 /// </summary>
 /// <param name="a">First item to compare.</param>
 /// <param name="b">Second item to compare.</param>
 /// <returns>&lt; if a &lt; b, 0 if a == b, &gt; if a &gt; b.</returns>
 public static Int32 ComparePublicIds(IPublicId a, IPublicId b) => CompareGuids(a.AsUuidArray, b.AsUuidArray);
Exemple #13
0
 /// <summary>
 /// Write a stream of Uuids (guids) to output stream.
 /// </summary>
 /// <param name="publicId">publicId to write.</param>
 public void PutPublicId(IPublicId publicId) => this.WriteUuids(publicId.AsUuidArray);
Exemple #14
0
        /// <summary>
        /// Create serialized output test cases.
        /// These can be read into java side to compare java and c# implementations.
        /// </summary>
        public List <ComponentDTO> CreateComponents()
        {
            List <ComponentDTO> retVal = new List <ComponentDTO>();

            {
                IPublicId pid = NextPublicId(1);
                // Write ConceptChronologyDTO.
                ConceptChronologyDTO dto = new ConceptChronologyDTO(
                    pid,
                    new ConceptVersionDTO[]
                {
                    new ConceptVersionDTO(pid, NextStamp()),
                    new ConceptVersionDTO(pid, NextStamp())
                }.ToImmutableArray()
                    );
                retVal.Add(dto);
            }
            {
                ConceptDTO dto = new ConceptDTO(NextPublicId(4));
                retVal.Add(dto);
            }
            {
                IPublicId            pid = NextPublicId(1);
                PatternChronologyDTO dto = new PatternChronologyDTO(
                    pid,
                    new PatternVersionDTO[]
                {
                    new PatternVersionDTO(
                        pid,
                        NextStamp(),
                        NextPublicId(4),
                        NextPublicId(5),
                        new FieldDefinitionDTO[] {
                        new FieldDefinitionDTO(
                            NextPublicId(4),
                            NextPublicId(3),
                            NextPublicId(2)
                            ),
                        new FieldDefinitionDTO(
                            NextPublicId(1),
                            NextPublicId(2),
                            NextPublicId(3)
                            )
                    }.ToImmutableArray()
                        )
                }.ToImmutableArray()
                    );

                retVal.Add(dto);
            }
            {
                PatternDTO dto = new PatternDTO(NextPublicId(2));
                retVal.Add(dto);
            }
            {
                IPublicId componentPublicId           = NextPublicId(4);
                IPublicId patternForSemanticPublicId  = NextPublicId(3);
                IPublicId referencedComponentPublicId = NextPublicId(2);

                SemanticChronologyDTO dto = new SemanticChronologyDTO(
                    componentPublicId,
                    patternForSemanticPublicId,
                    referencedComponentPublicId,
                    new SemanticVersionDTO[]
                {
                    new SemanticVersionDTO(
                        componentPublicId,
                        NextStamp(),
                        new Object[]
                    {
                        true, false,
                        new byte[] { }, new byte[] { 1, 2, 3 },
                        0.3F,
                        -1, 0, 1,
                        "abcdef",
                        new DateTime(2020, 1, 2),
                        new SpatialPointDTO(1, 2, 3),
                        new PlanarPointDTO(-1, -2)
                    }.ToImmutableArray()
                        )
                }.ToImmutableArray()
                    );

                retVal.Add(dto);
            }
            {
                SemanticDTO dto = new SemanticDTO(NextPublicId(4));
                retVal.Add(dto);
            }
            {
                SemanticVersionDTO dto =
                    new SemanticVersionDTO(
                        NextPublicId(3),
                        NextStamp(),
                        new Object[]
                {
                    true, false,
                    new byte[] { }, new byte[] { 1, 2, 3 },
                    0.3F,
                    -1, 0, 1,
                    "abcdef",
                    new DateTime(2020, 1, 2),
                    new SpatialPointDTO(1, 2, 3),
                    new PlanarPointDTO(-1, -2)
                }.ToImmutableArray()
                        );
            }
            return(retVal);
        }