internal override string SerializeParameter()
        {
            NamedProperty descriptionProperty = new NamedProperty()
            {
                Name  = "Description",
                Type  = "String",
                Value = Value.Description
            };
            NamedProperty groupProperty = new NamedProperty()
            {
                Name  = "Group",
                Type  = "String",
                Value = Value.Group
            };
            NamedProperty idProperty = new NamedProperty()
            {
                Name  = "Id",
                Type  = "String",
                Value = Value.Id
            };
            NamedProperty nameProperty = new NamedProperty()
            {
                Name  = "Name",
                Type  = "String",
                Value = Value.Name
            };
            NamedProperty parentProperty = new NamedProperty()
            {
                Name  = "ParentContentType",
                Type  = "String",
                Value = Value.ParentContentType
            };

            return($"<{ParameterTagName} TypeId=\"{TypeId}\">{descriptionProperty.ToString() + groupProperty.ToString() + idProperty.ToString() + nameProperty.ToString() + parentProperty.ToString()}</{ParameterTagName}>");
        }
Ejemplo n.º 2
0
        public bool TryResolveFromNamedProperty(NamedProperty namedProperty, ref PropertyTag propertyTag)
        {
            ushort num;

            try
            {
                if (namedProperty.Kind == NamedPropertyKind.String)
                {
                    num = this.pstMailbox.IPst.ReadIdFromNamedProp(namedProperty.Name, 0U, namedProperty.Guid, true);
                }
                else
                {
                    num = this.pstMailbox.IPst.ReadIdFromNamedProp(null, namedProperty.Id, namedProperty.Guid, true);
                }
            }
            catch (PSTExceptionBase innerException)
            {
                throw new MailboxReplicationPermanentException(new LocalizedString(this.pstMailbox.IPst.FileName), innerException);
            }
            if (num != 0)
            {
                propertyTag = new PropertyTag((PropertyId)num, propertyTag.PropertyType);
                return(true);
            }
            propertyTag = PropertyTag.CreateError(propertyTag.PropertyId);
            return(false);
        }
        public override void SetValue(NamedProperty val)
        {
            string          nameStr    = string.Empty;
            string          valStr     = string.Empty;
            string          typeStr    = string.Empty;
            string          contentStr = string.Empty;
            KDMEnumProperty enumProp   = null;


            if (val != null)
            {
                nameStr  = val.GetName();
                enumProp = val.Property as KDMEnumProperty;
                if (enumProp != null)
                {
                    valStr     = enumProp.GetValue().ToString();
                    typeStr    = enumProp.GetValue().Factory.Name;
                    contentStr = enumProp.GetValue().Factory.Name;
                }
            }

            //if (m_name != null)
            //    m_name.text = nameStr;

            //if (valStr != null)
            //    m_name.text = valStr;

            //if (m_type != null)
            //    m_type.text = typeStr;

            //if (m_content != null)
            //    m_content.text = contentStr;
        }
        public void NamedProperties_Test()
        {
            var namedIdMap = IntegrationUtil.GetNameIdMap();

            NamedProperty namedProperty = (NamedProperty)namedIdMap.NamedProperties.ElementAt(NameIdMapMockConstants.NAME_ID_MAP_FIRST_ELEMENT);

            Assert.AreEqual(NameIdMapMockConstants.NAMED_IDMAP_VALID_NAMED_PROPERTY, namedProperty.ID);
        }
Ejemplo n.º 5
0
        public void NamedPropertyBag_Test()
        {
            var namedIdMap = IntegrationUtil.GetNameIdMap();

            NamedProperty namedProperty = (NamedProperty)namedIdMap.NamedProperties.ElementAt <INamedProperty>(0);

            Assert.AreEqual(MockConstants.NAMED_IDMAP_VALID_NAMED_PROPERTY, namedProperty.ID);
        }
Ejemplo n.º 6
0
        public void NamedProperty_Created(string propertyName)
        {
            // Arrange, Act
            var property = new NamedProperty(propertyName);

            // Assert
            Assert.True(property.NeedsDelimiter);
            Assert.Equal(expected: propertyName, actual: property.ToString());
        }
Ejemplo n.º 7
0
        public void BuildNamedPropertyTest()
        {
            PrivateObject      param0   = null;                           // TODO: Initialize to an appropriate value
            NameIdMap_Accessor target   = new NameIdMap_Accessor(param0); // TODO: Initialize to an appropriate value
            NameId             id       = new NameId();                   // TODO: Initialize to an appropriate value
            NamedProperty      expected = null;                           // TODO: Initialize to an appropriate value
            NamedProperty      actual;

            actual = target.BuildNamedProperty(id);
            Assert.AreEqual(expected, actual);
            Assert.Inconclusive("Verify the correctness of this test method.");
        }
Ejemplo n.º 8
0
        public static object GetNamedPropertyValue(NamedProperty property)
        {
            ThrowIf.Null(property, "property");
            object propertyValue = null;

            // Special case GetValue calls (See Bug: 860194 for details)...
            FabricErrorCode errorCode = (FabricErrorCode)FabricClientState.HandleException(() => propertyValue = property.GetValue <object>());

            if (errorCode != 0 && errorCode != FabricErrorCode.PropertyValueEmpty)
            {
                throw new InvalidOperationException(string.Format(CultureInfo.InvariantCulture, "GetProperty failed with an unexpected error code {0}", errorCode));
            }

            return(propertyValue);
        }
Ejemplo n.º 9
0
        /// <summary>
        /// 设置一个属性的值
        /// </summary>
        /// <typeparam name="T">属性值类型</typeparam>
        /// <param name="propName">属性名称</param>
        /// <param name="propValue">属性值</param>
        public void SetValue <T>(NamedProperty <T> propName, T propValue)
        {
            if (propName == null)
            {
                throw new ArgumentNullException("propName", "参数不能为空");
            }

            if (!Properties.ContainsKey(propName.Name))
            {
                Properties.Add(propName.Name, propValue == null ? propName.DefaultValue : propValue);
            }
            else
            {
                Properties[propName.Name] = propValue == null ? propName.DefaultValue : propValue;
            }
        }
Ejemplo n.º 10
0
        AnnotatedPropertyValue IPropertyBag.GetAnnotatedProperty(PropertyTag propertyTag)
        {
            NamedProperty namedProperty = null;
            object        obj           = this[propertyTag];
            PropertyValue propertyValue = (obj != null) ? new PropertyValue(propertyTag, obj) : PropertyValue.Error(propertyTag.PropertyId, (ErrorCode)2147746063U);

            if (propertyTag.IsNamedProperty)
            {
                this.session.TryResolveToNamedProperty(propertyTag, out namedProperty);
                if (namedProperty == null)
                {
                    propertyValue = PropertyValue.Error(propertyTag.PropertyId, (ErrorCode)2147746063U);
                }
            }
            return(new AnnotatedPropertyValue(propertyTag, propertyValue, namedProperty));
        }
Ejemplo n.º 11
0
 /// <summary>
 /// 取得属性的值
 /// </summary>
 /// <typeparam name="T">属性值类型</typeparam>
 /// <param name="propName">属性名称</param>
 /// <returns>对象属性值</returns>
 public T GetValue <T>(NamedProperty <T> propName)
 {
     if (propName == null)
     {
         throw new ArgumentNullException("propName", "参数不能为空");
     }
     if (Properties.ContainsKey(propName.Name))
     {
         object obj = Properties[propName.Name];
         if ((obj as DBNull) == null)
         {
             return(propName.DefaultValue);
         }
         return((T)Convert.ChangeType(Properties[propName.Name], typeof(T)));
     }
     return(propName.DefaultValue);
 }
Ejemplo n.º 12
0
        internal NamedProperty MapProperty(PropertyEntry entry)
        {
            int           entryStreamIndex = GetEntryStreamIndex(entry.PropertyTag.ID); //find the index into the entry stream
            var           propEntry        = _propParser.Entries[entryStreamIndex];     //grab the relevent entry
            int           guidIndex        = GetGuidStreamIndex(propEntry.GUIDIndex);   //find the index into the guid stream
            Guid          guid             = _propParser.Guids[guidIndex];
            NamedProperty namedProperty    = new NamedProperty()
            {
                GUID = guid, Entry = entry, ID = propEntry.NameIdentifier
            };

            if (propEntry.IsString)
            {
                string name = _propParser.ReadStringStream(propEntry.NameIdentifier);
                namedProperty.Name = name;
            }
            return(namedProperty);
        }
 private void AddProperty(IfcObject ifcObject, IfcValue value, string cobiePropertyName, IfcPropertySet propertySet,
                          NamedProperty namedProperty)
 {
     try
     {
         var property = TargetRepository.Instances.New <IfcPropertySingleValue>();
         property.NominalValue = value;
         property.Description  = "Converted from COBie " + cobiePropertyName;
         property.Name         = namedProperty.PropertyName;
         propertySet.HasProperties.Add(property);
         var relDef = TargetRepository.Instances.New <IfcRelDefinesByProperties>();
         relDef.RelatingPropertyDefinition = propertySet;
         relDef.RelatedObjects.Add(ifcObject);
     }
     catch (Exception e)
     {
         throw new Exception("Failed to convert a COBie Value to and Ifc Single Value Property. " + e.Message);
     }
 }
Ejemplo n.º 14
0
        public bool TryResolveToNamedProperty(PropertyTag propertyTag, out NamedProperty namedProperty)
        {
            namedProperty = null;
            INamedProperty namedProperty2 = null;

            if (!propertyTag.IsNamedProperty || !this.pstMailbox.IPst.ReadNamedPropertyTable().TryGetValue((ushort)propertyTag.PropertyId, out namedProperty2))
            {
                return(false);
            }
            try
            {
                namedProperty = (namedProperty2.IsString ? new NamedProperty(namedProperty2.Guid, namedProperty2.Name) : new NamedProperty(namedProperty2.Guid, namedProperty2.Id));
            }
            catch (ArgumentException ex)
            {
                throw new ExArgumentException(ex.Message, ex);
            }
            return(true);
        }
Ejemplo n.º 15
0
        public AnnotatedPropertyValue GetAnnotatedProperty(PropertyTag propertyTag)
        {
            NamedProperty namedProperty = null;

            if (propertyTag.PropertyId == PropertyTag.Html.PropertyId)
            {
                propertyTag = PropertyTag.Html;
            }
            PropertyValue propertyValue = this.GetProperty(propertyTag);

            if (propertyTag.IsNamedProperty)
            {
                this.session.TryResolveToNamedProperty(propertyTag, out namedProperty);
                if (namedProperty == null)
                {
                    propertyValue = PropertyValue.Error(propertyTag.PropertyId, (ErrorCode)2147746063U);
                }
            }
            return(new AnnotatedPropertyValue(propertyTag, propertyValue, namedProperty));
        }
Ejemplo n.º 16
0
        public void NamedProperty_Equals(string name1, string name2, bool expected)
        {
            // Arrange
            NamedProperty prop1 = new NamedProperty(name1);
            NamedProperty prop2;

            if (name2 == null)
            {
                prop2 = null;
            }
            else
            {
                prop2 = new NamedProperty(name2);
            }

            // Act
            var result = prop1.Equals(prop2);

            // Assert
            Assert.Equal(expected: expected, actual: result);
        }
Ejemplo n.º 17
0
        private static string GetValue(NamedProperty property)
        {
            switch (property.Metadata.TypeId)
            {
            case PropertyTypeId.String:
                return(property.GetValue <string>());

            case PropertyTypeId.Double:
                return(property.GetValue <double>().ToString());

            case PropertyTypeId.Guid:
                return(property.GetValue <Guid>().ToString());

            case PropertyTypeId.Int64:
                return(property.GetValue <Int64>().ToString());

            case PropertyTypeId.Binary:
                return("binary " + property.Metadata.ValueSize + " bytes");

            case PropertyTypeId.Invalid:
            default:
                return("invalid");
            }
        }
        private void AddQuantity(ValueBaseType valueBaseType, string cobiePropertyName,
                                 IfcUnitConverter actualUnits, IfcElementQuantity propertySetDefinition, NamedProperty namedProperty)
        {
            try
            {
                var cobieValue = valueBaseType.ConvertTo <double>(); //quantities are always doubles
                if (actualUnits.IsUndefined)
                {
                    throw new ArgumentException("Invalid unit type " + actualUnits.UserDefinedSiUnitName +
                                                " has been pass to CreatePropertySingleValue");
                }

                IfcPhysicalQuantity quantity;

                switch (actualUnits.UnitName)
                //they are all here for future proofing, time, mass and count though are not really used by COBie
                {
                case IfcUnitEnum.AREAUNIT:
                    quantity =
                        TargetRepository.Instances.New <IfcQuantityArea>(
                            q => q.AreaValue = new IfcAreaMeasure(cobieValue));
                    break;

                case IfcUnitEnum.LENGTHUNIT:
                    quantity =
                        TargetRepository.Instances.New <IfcQuantityLength>(
                            q => q.LengthValue = new IfcLengthMeasure(cobieValue));
                    break;

                case IfcUnitEnum.MASSUNIT:
                    quantity =
                        TargetRepository.Instances.New <IfcQuantityWeight>(
                            q => q.WeightValue = new IfcMassMeasure(cobieValue));
                    break;

                case IfcUnitEnum.TIMEUNIT:
                    quantity =
                        TargetRepository.Instances.New <IfcQuantityTime>(
                            q => q.TimeValue = new IfcTimeMeasure(cobieValue));
                    break;

                case IfcUnitEnum.VOLUMEUNIT:
                    quantity =
                        TargetRepository.Instances.New <IfcQuantityVolume>(
                            q => q.VolumeValue = new IfcVolumeMeasure(cobieValue));
                    break;

                case IfcUnitEnum.USERDEFINED:     //we will treat this as Item for now
                    quantity =
                        TargetRepository.Instances.New <IfcQuantityCount>(
                            q => q.CountValue = new IfcCountMeasure(cobieValue));
                    break;

                default:
                    throw new ArgumentOutOfRangeException();
                }
                quantity.Description = "Converted from COBie " + cobiePropertyName;
                quantity.Name        = namedProperty.PropertyName;
                propertySetDefinition.Quantities.Add(quantity);
            }
            catch (Exception e)
            {
                throw new Exception("Failed to convert a COBie Value to and Ifc Quantity. " + e.Message);
            }
        }
 public override void SetValue(NamedProperty val)
 {
     throw new NotImplementedException();
 }
 public abstract void SetValue(NamedProperty val);
Ejemplo n.º 21
0
 public NamedPropertyWrapper(NamedProperty namedProperty)
 {
     this.namedProperty = namedProperty;
 }
Ejemplo n.º 22
0
 bool ISession.TryResolveFromNamedProperty(NamedProperty namedProperty, ref PropertyTag propertyTag)
 {
     return(false);
 }
Ejemplo n.º 23
0
 bool ISession.TryResolveToNamedProperty(PropertyTag propertyTag, out NamedProperty namedProperty)
 {
     namedProperty = null;
     return(propertyTag.IsNamedProperty && this.propertyTagToNamedProperties.TryGetValue(propertyTag, out namedProperty));
 }