Ejemplo n.º 1
0
        /// <summary>
        /// Instantiate and deserialize the properties of a <paramref name="PrefixedUnit"/>
        /// </summary>
        /// <param name="jObject">The <see cref="JObject"/> containing the data</param>
        /// <returns>The <see cref="PrefixedUnit"/> to instantiate</returns>
        public static CDP4Common.DTO.PrefixedUnit FromJsonObject(JObject jObject)
        {
            var iid            = jObject["iid"].ToObject <Guid>();
            var revisionNumber = jObject["revisionNumber"].IsNullOrEmpty() ? 0 : jObject["revisionNumber"].ToObject <int>();
            var prefixedUnit   = new CDP4Common.DTO.PrefixedUnit(iid, revisionNumber);

            if (!jObject["alias"].IsNullOrEmpty())
            {
                prefixedUnit.Alias.AddRange(jObject["alias"].ToObject <IEnumerable <Guid> >());
            }

            if (!jObject["definition"].IsNullOrEmpty())
            {
                prefixedUnit.Definition.AddRange(jObject["definition"].ToObject <IEnumerable <Guid> >());
            }

            if (!jObject["excludedDomain"].IsNullOrEmpty())
            {
                prefixedUnit.ExcludedDomain.AddRange(jObject["excludedDomain"].ToObject <IEnumerable <Guid> >());
            }

            if (!jObject["excludedPerson"].IsNullOrEmpty())
            {
                prefixedUnit.ExcludedPerson.AddRange(jObject["excludedPerson"].ToObject <IEnumerable <Guid> >());
            }

            if (!jObject["hyperLink"].IsNullOrEmpty())
            {
                prefixedUnit.HyperLink.AddRange(jObject["hyperLink"].ToObject <IEnumerable <Guid> >());
            }

            if (!jObject["isDeprecated"].IsNullOrEmpty())
            {
                prefixedUnit.IsDeprecated = jObject["isDeprecated"].ToObject <bool>();
            }

            if (!jObject["modifiedOn"].IsNullOrEmpty())
            {
                prefixedUnit.ModifiedOn = jObject["modifiedOn"].ToObject <DateTime>();
            }

            if (!jObject["prefix"].IsNullOrEmpty())
            {
                prefixedUnit.Prefix = jObject["prefix"].ToObject <Guid>();
            }

            if (!jObject["referenceUnit"].IsNullOrEmpty())
            {
                prefixedUnit.ReferenceUnit = jObject["referenceUnit"].ToObject <Guid>();
            }

            if (!jObject["thingPreference"].IsNullOrEmpty())
            {
                prefixedUnit.ThingPreference = jObject["thingPreference"].ToObject <string>();
            }

            return(prefixedUnit);
        }
Ejemplo n.º 2
0
        public void SetUp()
        {
            this.uri       = new Uri("http://www.rheagroup.com");
            this.cache     = new List <Thing>();
            this.testInput = new List <CDP4Common.DTO.Thing>();

            this.person = new CDP4Common.DTO.Person(Guid.NewGuid(), 0)
            {
                Surname = "test", Password = "******", IsActive = true
            };
            this.person2 = new CDP4Common.DTO.Person(Guid.NewGuid(), 0)
            {
                Surname = "test2", Password = "******", IsActive = true
            };
            var phone1 = new CDP4Common.DTO.TelephoneNumber(Guid.NewGuid(), 0)
            {
                Value = "123"
            };

            phone1.VcardType.Add(VcardTelephoneNumberKind.HOME);
            var phone2 = new CDP4Common.DTO.TelephoneNumber(Guid.NewGuid(), 0)
            {
                Value = "456"
            };

            phone2.VcardType.Add(VcardTelephoneNumberKind.WORK);
            var phone3 = new CDP4Common.DTO.TelephoneNumber(Guid.NewGuid(), 0)
            {
                Value = "789"
            };

            phone3.VcardType.Add(VcardTelephoneNumberKind.FAX);

            this.linearConversionUnitType = new CDP4Common.DTO.LinearConversionUnit(Guid.NewGuid(), 0);
            this.prefixedUnitType         = new CDP4Common.DTO.PrefixedUnit(Guid.NewGuid(), 0);
            this.derivedUnitType          = new CDP4Common.DTO.DerivedUnit(Guid.NewGuid(), 0);
            this.simpleUnitUnitType       = new CDP4Common.DTO.SimpleUnit(Guid.NewGuid(), 0);

            this.person.TelephoneNumber.Add(phone1.Iid);
            this.person.TelephoneNumber.Add(phone2.Iid);
            this.person.TelephoneNumber.Add(phone3.Iid);

            this.testInput.Add(new SiteDirectory(Guid.NewGuid(), 1));
            this.testInput.Add(this.person);
            this.testInput.Add(this.person2);
            this.testInput.Add(phone1);
            this.testInput.Add(phone2);
            this.testInput.Add(phone3);

            this.testInput.Add(this.linearConversionUnitType);
            this.testInput.Add(this.prefixedUnitType);
            this.testInput.Add(this.derivedUnitType);
            this.testInput.Add(this.simpleUnitUnitType);
        }