public void Test_can_resolve_meta_data_property_type(string propertyName, PropertyDataType expectedResult)
        {
            // Arrange
            PropertyDataTypeResolver resolver = new PropertyDataTypeResolver(null);

            // Act
            bool successfullyResolvedProperty =
                resolver.TryResolve(propertyName, out PropertyDataType resolvedPropertyDataType);

            // Assert
            successfullyResolvedProperty.Should().BeTrue();
            resolvedPropertyDataType.ShouldBeEquivalentTo(expectedResult);
        }
Пример #2
0
        /// <summary>
        /// Deserialize next object from a FastTransferStream.
        /// </summary>
        /// <param name="stream">A FastTransferStream.</param>
        public override void ConsumeNext(FastTransferStream stream)
        {
            base.ConsumeNext(stream);
            PropertyDataType type = (PropertyDataType)this.PropType;

            switch (type)
            {
            case PropertyDataType.PtypInteger16:
                this.fixedValue = stream.ReadInt16();
                break;

            case PropertyDataType.PtypInteger32:
                this.fixedValue = stream.ReadInt32();
                break;

            case PropertyDataType.PtypFloating32:
                this.fixedValue = stream.ReadFloating32();
                break;

            case PropertyDataType.PtypFloating64:
                this.fixedValue = stream.ReadFloating64();
                break;

            case PropertyDataType.PtypCurrency:
                this.fixedValue = stream.ReadCurrency();
                break;

            case PropertyDataType.PtypFloatingTime:
                this.fixedValue = stream.ReadFloatingTime();
                break;

            case PropertyDataType.PtypBoolean:
                this.fixedValue = stream.ReadBoolean();
                break;

            case PropertyDataType.PtypInteger64:
                this.fixedValue = stream.ReadInt64();
                break;

            case PropertyDataType.PtypTime:
                this.fixedValue = stream.ReadTime();
                break;

            case PropertyDataType.PtypGuid:
                this.fixedValue = stream.ReadGuid();
                break;
            }
        }
Пример #3
0
        private IDictionary <long, PropertyDataType> BuildDataTypeMap(long[] dataTypeIds, IDictionary <long, ObjectContainer> idToObj)
        {
            var r = new Dictionary <long, PropertyDataType>();

            foreach (var dataTypeId in dataTypeIds)
            {
                if (!idToObj.ContainsKey(dataTypeId))
                {
                    throw new Exception("Unknown datatype object ID=" + dataTypeId.ToString());
                }
                var dataTypeObj = idToObj[dataTypeId];
                var dataType    = dataTypeObj[OwlConfig.SuperIdPropertyID] as string;
                r[dataTypeId] = PropertyDataType.FindByID(dataType);
            }
            return(r);
        }
        public void WHEN_Passing_Known_PropertyName_SHOULD_Use_Known_Format(PropertyDataType dataType, string expectedFormatted)
        {
            //Arrange
            ProductFormatter          productFormatter = _container.CreateInstance <ProductFormatter>();
            ProductPropertyDefinition ppd = new ProductPropertyDefinition
            {
                PropertyName = "KnownPropertyName",
                DataType     = dataType
            };
            object value = new object();

            //Act
            string formatted = productFormatter.FormatValue(ppd, value, GetRandomCulture());

            //Assert
            formatted.Should().BeEquivalentTo(expectedFormatted);
        }
Пример #5
0
        /// <summary>
        /// 基本类型转换到PropertyDataType
        /// </summary>
        /// <param name="type"></param>
        /// <returns></returns>
        public static PropertyDataType ToPropertyDataType(this System.Type type)
        {
            type.NullCheck("type");

            PropertyDataType result = PropertyDataType.DataObject;

            foreach (KeyValuePair <PropertyDataType, System.Type> kp in _DataTypeMappings)
            {
                if (kp.Value == type)
                {
                    result = kp.Key;
                    break;
                }
            }

            return(result);
        }
        public void Test_can_resolve_property_type()
        {
            // Arrange
            const string           propertyName     = "TestProperty";
            const PropertyDataType propertyDataType = PropertyDataType.Boolean;

            ContentType contentType = new ContentType();

            contentType.PropertyDefinitions.Add(new PropertyDefinition
            {
                Name = propertyName,
                Type = new PropertyDefinitionType(1, propertyDataType, "Boolean")
            });

            PropertyDataTypeResolver resolver = new PropertyDataTypeResolver(contentType);

            // Act
            bool successfullyResolvedProperty =
                resolver.TryResolve(propertyName, out PropertyDataType resolvedPropertyDataType);

            // Assert
            successfullyResolvedProperty.Should().BeTrue();
            resolvedPropertyDataType.ShouldBeEquivalentTo(propertyDataType);
        }
        internal bool TryResolve(string propertyIdentifier, out PropertyDataType propertyDataType)
        {
            Debug.Assert(!string.IsNullOrWhiteSpace(propertyIdentifier));

            propertyDataType = PropertyDataType.String;
            if (MetaDataPropertyTypeMappings.ContainsKey(propertyIdentifier))
            {
                propertyDataType = MetaDataPropertyTypeMappings[propertyIdentifier];
                return(true);
            }

            PropertyDefinition propDef = _contentType
                                         .PropertyDefinitions
                                         .SingleOrDefault(prop =>
                                                          prop.Name.Equals(propertyIdentifier, StringComparison.InvariantCultureIgnoreCase));

            if (propDef != null)
            {
                propertyDataType = propDef.Type.DataType;
                return(true);
            }

            return(false);
        }
Пример #8
0
 /// <summary>
 /// Indicate whether a PropertyDataType is a multi-valued property type.
 /// </summary>
 /// <param name="type">A PropertyDataType.</param>
 /// <returns>If the PropertyDataType is a multi-value type
 /// return true, else false.</returns>
 public static bool IsMVType(PropertyDataType type)
 {
     return(mvtypes.Contains(type));
 }
Пример #9
0
        private object CovertValueToRequiredDataType(string value,
                                                     PropertyDataType propertyDataType = PropertyDataType.String,
                                                     Type enumType         = null,
                                                     string dateTimeFormat = null)
        {
            if (value == null || string.IsNullOrWhiteSpace(value))
            {
                return(null);
            }

            switch (propertyDataType)
            {
            case PropertyDataType.String:
                return(value);

            case PropertyDataType.Decimal:
                if (Decimal.TryParse(value, out decimal decVal))
                {
                    return(decVal);
                }
                else
                {
                    return(null);
                }

            case PropertyDataType.Boolean:
                if (bool.TryParse(value, out bool boolVal))
                {
                    return(boolVal);
                }
                else
                {
                    return(null);
                }

            case PropertyDataType.Time:
                var format = dateTimeFormat ?? "MM/dd/yyyy-HH:mm:ss.FFF";
                if (DateTime.TryParseExact(value, format, new CultureInfo("en-US"), DateTimeStyles.None, out DateTime datetimeVal))
                {
                    return(datetimeVal);
                }
                else
                {
                    return(null);
                }

            case PropertyDataType.Hexadecimal:
                return(Convert.ToSByte(value, 16));

            case PropertyDataType.Enum:
                if (enumType != null)
                {
                    if (NongenericEnumHelper.TryParse(enumType, value, true, out object enumValue))
                    {
                        return(enumValue);
                    }
                    else
                    {
                        return(null);
                    }
                }
                else
                {
                    return(null);
                }

            default:
                return(value);
            }
        }
Пример #10
0
        /// <summary>
        /// 试图转换成真实的类型
        /// </summary>
        /// <param name="pdt"></param>
        /// <param name="type"></param>
        /// <returns></returns>
        public static bool TryToRealType(this PropertyDataType pdt, out Type type)
        {
            type = typeof(string);

            return(_DataTypeMappings.TryGetValue(pdt, out type));
        }
Пример #11
0
 public PropertyDataTypeAttribute(PropertyDataType dataType)
 {
     this.DataType = dataType;
 }
 /// <summary>
 /// Indicate whether a PropertyDataType is either PtypString, PtypString8 or PtypBinary, PtypServerId, or PtypObject. 
 /// </summary>
 /// <param name="type">A PropertyDataType.</param>
 /// <returns>If the PropertyDataType is a either PtypString, PtypString8 or PtypBinary, PtypServerId, or PtypObject return true, else false.</returns>
 public static bool IsVarType(PropertyDataType type)
 {
     return VarTypes.Contains(type);
 }
 /// <summary>
 /// Parse the AddressBookFlaggedPropertyValueWithType structure.
 /// </summary>
 /// <param name="s">An stream containing AddressBookFlaggedPropertyValueWithType structure.</param>
 public override void Parse(Stream s)
 {
     base.Parse(s);
     this.PropertyType = (PropertyDataType)ReadUshort();
     this.Flag = ReadByte();
     if (this.Flag != 0x01)
     {
         if (this.Flag == 0x00)
         {
             AddressBookPropertyValue addressPropValue = new AddressBookPropertyValue(PropertyType);
             addressPropValue.Parse(s);
             this.PropertyValue = addressPropValue;
         }
         else if (this.Flag == 0x0A)
         {
             AddressBookPropertyValue addressPropValueForErrorCode = new AddressBookPropertyValue(PropertyDataType.PtypErrorCode);
             addressPropValueForErrorCode.Parse(s);
             this.PropertyValue = addressPropValueForErrorCode;
         }
     }
 }
 /// <summary>
 /// Parse the AddressBookTypedPropertyValue structure.
 /// </summary>
 /// <param name="s">An stream containing AddressBookTypedPropertyValue structure.</param>
 public override void Parse(Stream s)
 {
     base.Parse(s);
     this.PropertyType = (PropertyDataType)ReadUshort();
     AddressBookPropertyValue addressBookPropValue = new AddressBookPropertyValue(this.PropertyType);
     addressBookPropValue.Parse(s);
     this.PropertyValue = addressBookPropValue;
 }
Пример #15
0
        private void SetGenericProperties(int patternIndex, object parsedValue, string name, PropertyDataType dataType, string format)
        {
            if (_currentObj == null)
            {
                return;
            }

            _currentObj.SetDynProperty("Name", name);
            _currentObj.SetDynProperty("PatternIndex", patternIndex, PropertyDataType.Decimal);
            _currentObj.SetDynProperty("DataType", dataType, PropertyDataType.Enum, format, typeof(PropertyDataType));

            if (string.Equals(name, "Time", StringComparison.InvariantCultureIgnoreCase))
            {
                _currentObj.SetDynProperty("Time", parsedValue, PropertyDataType.Time, format);
            }
        }
        public void WHEN_Passing_Unknown_PropertyName_For_Lookup_SHOULD_Format_Using_BasePropertyTypeKey(PropertyDataType dataType, string expectedFormatted)
        {
            //Arrange
            ProductFormatter          productFormatter = _container.CreateInstance <ProductFormatter>();
            ProductPropertyDefinition ppd = new ProductPropertyDefinition
            {
                PropertyName     = GetRandom.String(32),
                DataType         = dataType,
                LookupDefinition = new ProductLookupDefinition
                {
                    LookupName = GetRandom.String(32)
                }
            };
            object value = new object();

            //Act
            string formatted = productFormatter.FormatValue(ppd, value, GetRandomCulture());

            //Assert
            formatted.Should().BeEquivalentTo(expectedFormatted);
        }
 public virtual PropertyMetadata GetMetadataForClaim(string type, string name = null, PropertyDataType dataType = PropertyDataType.String, bool required = false)
 {
     return(PropertyMetadata.FromFunctions(type, this.GetForClaim(type), this.SetForClaim(type), name, dataType, required));
 }
Пример #18
0
 internal static TBuilder SetDataTypeCore <TBuilder>(TBuilder builder, PropertyDataType dataType) where TBuilder : IAttributeBuilderInternal <TBuilder>
 {
     return(builder.AddOrReplaceAttribute(new DataTypeAttribute(ToDataType(dataType))));
 }
 /// <summary>
 /// Indicate whether a PropertyDataType is a multi-valued property type.
 /// </summary>
 /// <param name="type">A PropertyDataType.</param>
 /// <returns>If the PropertyDataType is a multi-value type 
 /// return true, else false.</returns>
 public static bool IsMVType(PropertyDataType type)
 {
     return mvtypes.Contains(type);
 }
Пример #20
0
 /// <summary>
 /// Indicate whether a property type value of any type that has a fixed length.
 /// </summary>
 /// <param name="type">A property type.</param>
 /// <returns>If a property type value of any type that has a fixed length,
 /// return true , else return false.
 /// </returns>
 public static bool IsFixedType(PropertyDataType type)
 {
     return(fixedTypes.Contains(type));
 }
Пример #21
0
 /// <summary>
 /// Indicate whether a PropertyDataType is either
 /// PtypString, PtypString8 or PtypBinary, PtypServerId, or PtypObject.
 /// </summary>
 /// <param name="type">A PropertyDataType.</param>
 /// <returns>If the PropertyDataType is a either
 /// PtypString, PtypString8 or PtypBinary, PtypServerId, or PtypObject
 /// return true, else false.
 /// </returns>
 public static bool IsVarType(PropertyDataType type)
 {
     return(varTypes.Contains(type));
 }
 /// <summary>
 /// Parse the TypedPropertyValue structure.
 /// </summary>
 /// <param name="s">A stream containing the TypedPropertyValue structure</param>
 public override void Parse(Stream s)
 {
     base.Parse(s);
     this.PropertyType = (PropertyDataType)ReadUshort();
     PropertyValue propertyValue = new PropertyValue();
     this.PropertyValue = propertyValue.ReadPropertyValue(this.PropertyType, s, countWide);
 }
Пример #23
0
 public static ClientPropertyDataType ToClientPropertyDataType(this PropertyDataType pdt)
 {
     return((ClientPropertyDataType)pdt);
 }
Пример #24
0
 public DataFieldDefine(PropertyDataType dataType)
 {
     this.LoadPropertiesFromDataType(dataType);
     this._DataType = dataType;
 }
Пример #25
0
        private bool ValidateProfileDefinition(XElement profilePropDefinition, int lineNum, out string name, out PropertyDataType dataType, out string format)
        {
            dataType = PropertyDataType.String;
            format   = null;
            name     = null;

            if (profilePropDefinition.Element("Name") == null)
            {
                AppLogger.LogLine("Invalid profile definition: missing element 'Name' of the property", lineNum);
                return(false);
            }

            name = profilePropDefinition.Element("Name").Value;
            if (string.IsNullOrWhiteSpace(name))
            {
                AppLogger.LogLine("Invalid profile definition: element 'Name' is null or empty", lineNum);
                return(false);
            }

            if (profilePropDefinition.Element("DataType") == null)
            {
                AppLogger.LogLine(string.Format("Invalid profile definition: missing element '{0}' of property '{1}'", "DataType", name), lineNum);
                return(false);
            }
            dataType = profilePropDefinition.Element("DataType").Value.ToEnum <PropertyDataType>();

            format = dataType == PropertyDataType.Time ?
                     profilePropDefinition.Element("DataType").Attribute("Format").Value :
                     null;

            return(true);
        }
 /// <summary>
 /// The constructed function for AddressBookPropertyValue.
 /// </summary>
 /// <param name="propertyDataType">The PropertyDataType for this structure</param>
 /// <param name="ptypMultiCountSize">The CountWideEnum for this structure</param>
 public AddressBookPropertyValue(PropertyDataType propertyDataType, CountWideEnum ptypMultiCountSize = CountWideEnum.fourBytes)
 {
     this.propertyDataType = propertyDataType;
     this.countWide = ptypMultiCountSize;
 }
Пример #27
0
 public PropertyMetadata GetMetadataForClaim(string type, string name = null, PropertyDataType dataType = PropertyDataType.String, bool required = false)
 {
     return(PropertyMetadata.FromFunctions <TUser, string>(type, GetForClaim(type), SetForClaim(type), name, dataType, required));
 }
Пример #28
0
 protected void SetPropertyDataType(PropertyDataType type)
 {
     _dataType = type;
 }
 protected DXDataTypeAttribute(Func <string> errorMessageAccessor, Func <string> defaultErrorMessageAccessor, PropertyDataType dataType)
     : base(errorMessageAccessor, defaultErrorMessageAccessor)
 {
     this.DataType = dataType;
 }
 /// <summary>
 /// Indicate whether a property type value of any type that has a fixed length.
 /// </summary>
 /// <param name="type">A property type.</param>
 /// <returns>If a property type value of any type that has a fixed length, return true , else return false.</returns>
 public static bool IsFixedType(PropertyDataType type)
 {
     return FixedTypes.Contains(type);
 }
 /// <summary>
 /// The Constructor to set the Property data type and the Count wide size.
 /// </summary>
 /// <param name="propertyType">The Property data type.</param>
 /// <param name="ptypMultiCountSize">The Count wide size.</param>
 public FlaggedPropertyValue(PropertyDataType propertyType, CountWideEnum ptypMultiCountSize = CountWideEnum.twoBytes)
 {
     PropertyType = propertyType;
     countWide = ptypMultiCountSize;
 }
 /// <summary>
 /// Parse the PropertyTagWithGroupPropertyName structure.
 /// </summary>
 /// <param name="s">A stream containing the PropertyTagWithGroupPropertyName structure</param>
 public void Parse(FastTransferStream stream)
 {
     this.PropertyType = (PropertyDataType)stream.ReadUInt16();
     this.PropertyId = stream.ReadUInt16();
     if (this.PropertyId >= 0x8000)
     {
         this.groupPropertyName = new GroupPropertyName();
         this.groupPropertyName.Parse(stream);
     }
 }
 /// <summary>
 /// Initializes a new instance of the PropertyTag class with parameters.
 /// </summary>
 /// <param name="PType">The Type of the PropertyTag.</param>
 /// /// <param name="PId">The Id of the PropertyTag.</param>
 public PropertyTag(PropertyDataType PType, PidTagPropertyEnum PId)
 {
     this.PropertyType = PType;
     this.PropertyId = PId;
 }
Пример #34
0
 static PropertyMetadataBuilder <T, TProperty> SetDataTypeCore <T, TProperty>(this PropertyMetadataBuilder <T, TProperty> builder, PropertyDataType dataType)
 {
     return(DataAnnotationsAttributeHelper.SetDataTypeCore(builder, dataType));
 }
        /// <summary>
        /// The method to return the object of PropertyValue.
        /// </summary>
        /// <param name="dataType">The Property data type.</param>
        /// <param name="s">A stream containing the PropertyValue structure</param>
        /// <param name="ptypMultiCountSize">The Count wide size of ptypMutiple type.</param>
        /// <returns>The object of PropertyValue.</returns>
        public object ReadPropertyValue(PropertyDataType dataType, Stream s, CountWideEnum ptypMultiCountSize = CountWideEnum.twoBytes)
        {
            base.Parse(s);
            object propertyValue;
            switch (dataType)
            {
                case PropertyDataType.PtypInteger16:
                    {
                        PtypInteger16 tempPropertyValue = new PtypInteger16();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypInteger32:
                    {
                        PtypInteger32 tempPropertyValue = new PtypInteger32();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypFloating32:
                    {
                        PtypFloating32 tempPropertyValue = new PtypFloating32();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypFloating64:
                    {
                        PtypFloating64 tempPropertyValue = new PtypFloating64();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypCurrency:
                    {
                        PtypCurrency tempPropertyValue = new PtypCurrency();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypFloatingTime:
                    {
                        PtypFloatingTime tempPropertyValue = new PtypFloatingTime();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypErrorCode:
                    {
                        PtypErrorCode tempPropertyValue = new PtypErrorCode();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypBoolean:
                    {
                        PtypBoolean tempPropertyValue = new PtypBoolean();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypInteger64:
                    {
                        PtypInteger64 tempPropertyValue = new PtypInteger64();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypString:
                    {
                        PtypString tempPropertyValue = new PtypString();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypString8:
                    {
                        PtypString8 tempPropertyValue = new PtypString8();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypTime:
                    {
                        PtypTime tempPropertyValue = new PtypTime();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypGuid:
                    {
                        PtypGuid tempPropertyValue = new PtypGuid();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypServerId:
                    {
                        PtypServerId tempPropertyValue = new PtypServerId();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypRestriction:
                    {
                        PtypRestriction tempPropertyValue = new PtypRestriction();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypRuleAction:
                    {
                        PtypRuleAction tempPropertyValue = new PtypRuleAction();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypUnspecified:
                    {
                        PtypUnspecified tempPropertyValue = new PtypUnspecified();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypNull:
                    {
                        PtypNull tempPropertyValue = new PtypNull();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypBinary:
                    {
                        PtypBinary tempPropertyValue = new PtypBinary(ptypMultiCountSize);
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypMultipleInteger16:
                    {
                        PtypMultipleInteger16 tempPropertyValue = new PtypMultipleInteger16(ptypMultiCountSize);
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypMultipleInteger32:
                    {
                        PtypMultipleInteger32 tempPropertyValue = new PtypMultipleInteger32(ptypMultiCountSize);
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypMultipleFloating32:
                    {
                        PtypMultipleFloating32 tempPropertyValue = new PtypMultipleFloating32(ptypMultiCountSize);
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypMultipleFloating64:
                    {
                        PtypMultipleFloating64 tempPropertyValue = new PtypMultipleFloating64(ptypMultiCountSize);
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypMultipleCurrency:
                    {
                        PtypMultipleCurrency tempPropertyValue = new PtypMultipleCurrency(ptypMultiCountSize);
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypMultipleFloatingTime:
                    {
                        PtypMultipleFloatingTime tempPropertyValue = new PtypMultipleFloatingTime(ptypMultiCountSize);
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypMultipleInteger64:
                    {
                        PtypMultipleInteger64 tempPropertyValue = new PtypMultipleInteger64(ptypMultiCountSize);
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypMultipleString:
                    {
                        PtypMultipleString tempPropertyValue = new PtypMultipleString(ptypMultiCountSize);
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypMultipleString8:
                    {
                        PtypMultipleString8 tempPropertyValue = new PtypMultipleString8(ptypMultiCountSize);
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypMultipleTime:
                    {
                        PtypMultipleTime tempPropertyValue = new PtypMultipleTime(ptypMultiCountSize);
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypMultipleGuid:
                    {
                        PtypMultipleGuid tempPropertyValue = new PtypMultipleGuid(ptypMultiCountSize);
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypMultipleBinary:
                    {
                        PtypMultipleBinary tempPropertyValue = new PtypMultipleBinary(ptypMultiCountSize);
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;
                    }
                case PropertyDataType.PtypObject_Or_PtypEmbeddedTable:
                    {
                        PtypObject_Or_PtypEmbeddedTable tempPropertyValue = new PtypObject_Or_PtypEmbeddedTable();
                        tempPropertyValue.Parse(s);
                        propertyValue = tempPropertyValue;
                        break;

                    }
                default:
                    propertyValue = null;
                    break;
            }
            return propertyValue;
        }
Пример #36
0
        /// <summary>
        /// Creates a PropertyCriteria.
        /// </summary>
        /// <param name="condition">The condition for the comparison.</param>
        /// <param name="name">The name of the property.</param>
        /// <param name="dataType">Type of property data.</param>
        /// <param name="value">The value to evalute the property against.</param>
        /// <param name="required">If set to <c>true</c> the criteria is required, which makes it an AND search.</param>
        /// <returns></returns>
        public static PropertyCriteria CreateCriteria(CompareCondition condition, string name, PropertyDataType dataType, string value, bool required)
        {
            PropertyCriteria criteria = new PropertyCriteria();

            criteria.Condition = condition;
            criteria.Name      = name;
            criteria.Type      = dataType;
            criteria.Value     = value;
            criteria.Required  = required;

            return(criteria);
        }
Пример #37
0
 public PropertyDefinition(string name, PropertyDataType dataType, bool isRequired)
 {
     Name       = name;
     DataType   = dataType;
     IsRequired = isRequired;
 }
 public RegexAttributeBase(Regex regex, Func <string> errorMessageAccessor, Func <string> defaultErrorMessageAccessor, PropertyDataType dataType)
     : base(errorMessageAccessor, defaultErrorMessageAccessor, dataType)
 {
     this.regex = regex;
 }
Пример #39
0
 public RegexAttributeBase(Regex regex, Func<string> errorMessageAccessor, Func<string> defaultErrorMessageAccessor, PropertyDataType dataType)
     : base(errorMessageAccessor, defaultErrorMessageAccessor, dataType) {
     this.regex = regex;
 }
Пример #40
0
 private IDataType GetDataType(PropertyDataType dataType)
 {
     return(_DataTypeService.GetDataType((int)dataType));
 }
Пример #41
0
 protected DXDataTypeAttribute(Func<string> errorMessageAccessor, Func<string> defaultErrorMessageAccessor, PropertyDataType dataType)
     : base(errorMessageAccessor, defaultErrorMessageAccessor) {
     this.DataType = dataType;
 }
 /// <summary>
 /// Parse the FlaggedPropertyValueWithType structure.
 /// </summary>
 /// <param name="s">A stream containing the FlaggedPropertyValueWithType structure</param>
 public override void Parse(Stream s)
 {
     base.Parse(s);
     this.PropertyType = (PropertyDataType)ReadUshort();
     this.Flag = ReadByte();
     if (this.Flag == 0x00)
     {
         PropertyValue propertyValue = new PropertyValue();
         this.PropertyValue = propertyValue.ReadPropertyValue(this.PropertyType, s, countWide);
     }
     else if (this.Flag == 0x0A)
     {
         PropertyValue propertyValue = new PropertyValue();
         this.PropertyValue = propertyValue.ReadPropertyValue(PropertyDataType.PtypErrorCode, s, countWide);
     }
     else
     {
         this.PropertyValue = null;
     }
 }
Пример #43
0
 /// <summary>
 /// Initializes a new instance of the <see cref="PropertyMatchExpression"/> class.
 /// </summary>
 /// <param name="xpathOrMacro">The xpath or macro for the property.</param>
 /// <param name="dataType">The type of the data.</param>
 public PropertyMatchExpression(string xpathOrMacro, PropertyDataType dataType)
 {
     this.XpathOrMacro = xpathOrMacro;
     this.DataType     = dataType;
 }
 /// <summary>
 /// The Constructor to set the property type and Count wide size.
 /// </summary>
 /// <param name="ptypMultiCountSize">The Count wide size of ptypMutiple type.</param>
 public PropertyValue(PropertyDataType ProType, CountWideEnum ptypMultiCountSize = CountWideEnum.twoBytes)
 {
     countWide = ptypMultiCountSize;
     PropertyType = ProType;
 }
        public PsetProperty getPropertyDef(XNamespace ns, XElement pDef)
        {
            PsetProperty prop = new PsetProperty();

            if (pDef.Attribute("ifdguid") != null)
            {
                prop.IfdGuid = pDef.Attribute("ifdguid").Value;
            }
            prop.Name = pDef.Element(ns + "Name").Value;
            IList <NameAlias> aliases      = new List <NameAlias>();
            XElement          nAliasesElem = pDef.Elements(ns + "NameAliases").FirstOrDefault();

            if (nAliasesElem != null)
            {
                var nAliases = from el in nAliasesElem.Elements(ns + "NameAlias") select el;
                foreach (XElement alias in nAliases)
                {
                    NameAlias nameAlias = new NameAlias();
                    nameAlias.Alias = alias.Value;
                    nameAlias.lang  = alias.Attribute("lang").Value;
                    aliases.Add(nameAlias);
                }
            }
            if (aliases.Count > 0)
            {
                prop.NameAliases = aliases;
            }

            PropertyDataType dataTyp = null;
            var      propType        = pDef.Elements(ns + "PropertyType").FirstOrDefault();
            XElement propDetType     = propType.Elements().FirstOrDefault();

            if (propDetType == null)
            {
#if DEBUG
                logF.WriteLine("%Warning: Missing PropertyType for {0}.{1}", pDef.Parent.Parent.Element(ns + "Name").Value, prop.Name);
#endif
                return(prop);
            }

            if (propDetType.Name.LocalName.Equals("TypePropertySingleValue"))
            {
                XElement            dataType = propDetType.Element(ns + "DataType");
                PropertySingleValue sv       = new PropertySingleValue();
                if (dataType.Attribute("type") != null)
                {
                    sv.DataType = dataType.Attribute("type").Value;
                }
                else
                {
                    sv.DataType = "IfcLabel"; // Set this to default if missing
#if DEBUG
                    logF.WriteLine("%Warning: Missing TypePropertySingleValue for {0}.{1}", pDef.Parent.Parent.Element(ns + "Name").Value, prop.Name);
#endif
                }
                dataTyp = sv;
            }
            else if (propDetType.Name.LocalName.Equals("TypePropertyReferenceValue"))
            {
                PropertyReferenceValue rv = new PropertyReferenceValue();
                // Older versions uses Element DataType!
                XElement dt = propDetType.Element(ns + "DataType");
                if (dt == null)
                {
                    rv.RefEntity = propDetType.Attribute("reftype").Value;
                }
                else
                {
                    rv.RefEntity = dt.Attribute("type").Value;
                }
                dataTyp = rv;
            }
            else if (propDetType.Name.LocalName.Equals("TypePropertyEnumeratedValue"))
            {
                PropertyEnumeratedValue pev = new PropertyEnumeratedValue();
                var enumItems = propDetType.Descendants(ns + "EnumItem");
                if (enumItems.Count() > 0)
                {
                    pev.Name    = propDetType.Element(ns + "EnumList").Attribute("name").Value;
                    pev.EnumDef = new List <PropertyEnumItem>();
                    foreach (var en in enumItems)
                    {
                        string enumItemName            = en.Value.ToString();
                        IEnumerable <XElement> consDef = null;
                        if (propDetType.Element(ns + "ConstantList") != null)
                        {
                            consDef = from el in propDetType.Element(ns + "ConstantList").Elements(ns + "ConstantDef")
                                      where (el.Element(ns + "Name").Value.Equals(enumItemName, StringComparison.CurrentCultureIgnoreCase))
                                      select el;
                        }

                        if (propDetType.Element(ns + "ConstantList") != null)
                        {
                            var consList = propDetType.Element(ns + "ConstantList").Elements(ns + "ConstantDef");
                            if (consList != null && consList.Count() != enumItems.Count())
                            {
#if DEBUG
                                logF.WriteLine("%Warning: EnumList (" + enumItems.Count().ToString() + ") is not consistent with the ConstantList ("
                                               + consList.Count().ToString() + ") for: {0}.{1}",
                                               pDef.Parent.Parent.Element(ns + "Name").Value, prop.Name);
#endif
                            }
                        }

                        if (consDef != null && consDef.Count() > 0)
                        {
                            foreach (var cD in consDef)
                            {
                                PropertyEnumItem enumItem = new PropertyEnumItem();
                                enumItem.EnumItem = cD.Elements(ns + "Name").FirstOrDefault().Value;
                                enumItem.Aliases  = new List <NameAlias>();
                                var eAliases = from el in cD.Elements(ns + "NameAliases").FirstOrDefault().Elements(ns + "NameAlias") select el;
                                if (eAliases.Count() > 0)
                                {
                                    foreach (var aliasItem in eAliases)
                                    {
                                        NameAlias nal = new NameAlias();
                                        nal.Alias = aliasItem.Value;
                                        nal.lang  = aliasItem.Attribute("lang").Value;
                                        enumItem.Aliases.Add(nal);
                                    }
                                }
                                pev.EnumDef.Add(enumItem);
                            }
                        }
                        else
                        {
                            PropertyEnumItem enumItem = new PropertyEnumItem();
                            enumItem.EnumItem = enumItemName;
                            enumItem.Aliases  = new List <NameAlias>();
                            pev.EnumDef.Add(enumItem);
                        }
                    }
                }
                else
                {
                    {
#if DEBUG
                        logF.WriteLine("%Warning: EnumList {0}.{1} is empty!", pDef.Parent.Parent.Element(ns + "Name").Value, prop.Name);
#endif
                    }
                    // If EnumList is empty, try to see whether ConstantDef has values. The Enum item name will be taken from the ConstantDef.Name
                    pev.Name    = "PEnum_" + prop.Name;
                    pev.EnumDef = new List <PropertyEnumItem>();
                    var consDef = from el in propDetType.Element(ns + "ConstantList").Elements(ns + "ConstantDef")
                                  select el;
                    if (consDef != null && consDef.Count() > 0)
                    {
                        foreach (var cD in consDef)
                        {
                            PropertyEnumItem enumItem = new PropertyEnumItem();
                            enumItem.EnumItem = cD.Elements(ns + "Name").FirstOrDefault().Value;
                            enumItem.Aliases  = new List <NameAlias>();
                            var eAliases = from el in cD.Elements(ns + "NameAliases").FirstOrDefault().Elements(ns + "NameAlias") select el;
                            if (eAliases.Count() > 0)
                            {
                                foreach (var aliasItem in eAliases)
                                {
                                    NameAlias nal = new NameAlias();
                                    nal.Alias = aliasItem.Value;
                                    nal.lang  = aliasItem.Attribute("lang").Value;
                                    enumItem.Aliases.Add(nal);
                                }
                            }
                            pev.EnumDef.Add(enumItem);
                        }
                    }
                }
                dataTyp = pev;
            }
            else if (propDetType.Name.LocalName.Equals("TypePropertyBoundedValue"))
            {
                XElement             dataType = propDetType.Element(ns + "DataType");
                PropertyBoundedValue bv       = new PropertyBoundedValue();
                bv.DataType = dataType.Attribute("type").Value;
                dataTyp     = bv;
            }
            else if (propDetType.Name.LocalName.Equals("TypePropertyListValue"))
            {
                XElement          dataType = propDetType.Descendants(ns + "DataType").FirstOrDefault();
                PropertyListValue lv       = new PropertyListValue();
                lv.DataType = dataType.Attribute("type").Value;
                dataTyp     = lv;
            }
            else if (propDetType.Name.LocalName.Equals("TypePropertyTableValue"))
            {
                PropertyTableValue tv = new PropertyTableValue();
                var tve = propDetType.Element(ns + "Expression");
                if (tve != null)
                {
                    tv.Expression = tve.Value;
                }
                XElement el = propDetType.Element(ns + "DefiningValue");
                if (el != null)
                {
                    XElement el2 = propDetType.Element(ns + "DefiningValue").Element(ns + "DataType");
                    if (el2 != null)
                    {
                        tv.DefiningValueType = el2.Attribute("type").Value;
                    }
                }
                el = propDetType.Element(ns + "DefinedValue");
                if (el != null)
                {
                    XElement el2 = propDetType.Element(ns + "DefinedValue").Element(ns + "DataType");
                    if (el2 != null)
                    {
                        tv.DefinedValueType = el2.Attribute("type").Value;
                    }
                }
                dataTyp = tv;
            }
            else if (propDetType.Name.LocalName.Equals("TypeComplexProperty"))
            {
                ComplexProperty compProp = new ComplexProperty();
                compProp.Name       = propDetType.Attribute("name").Value;
                compProp.Properties = new List <PsetProperty>();
                foreach (XElement cpPropDef in propDetType.Elements(ns + "PropertyDef"))
                {
                    PsetProperty pr = getPropertyDef(ns, cpPropDef);
                    if (pr == null)
                    {
#if DEBUG
                        logF.WriteLine("%Error: Mising PropertyType data in complex property {0}.{1}.{2}", propDetType.Parent.Parent.Element(ns + "Name").Value,
                                       prop.Name, cpPropDef.Element(ns + "Name").Value);
#endif
                    }
                    else
                    {
                        compProp.Properties.Add(pr);
                    }
                }
                dataTyp = compProp;
            }
            prop.PropertyType = dataTyp;

            return(prop);
        }
 /// <summary>
 /// Parse the SortOrder structure.
 /// </summary>
 /// <param name="s">A stream containing the SortOrder structure</param>
 public override void Parse(Stream s)
 {
     base.Parse(s);
     this.PropertyType = (PropertyDataType)ReadUshort();
     this.PropertyId = (PidTagPropertyEnum)ReadUshort();
     this.Order = (OrderType)ReadByte();
 }
 /// <summary>
 /// The constructed function for AddressBookFlaggedPropertyValue
 /// </summary>
 /// <param name="propertyDataType">The PropertyDataType parameter for AddressBookFlaggedPropertyValue</param>
 public AddressBookFlaggedPropertyValue(PropertyDataType propertyDataType)
 {
     this.propertyDataType = propertyDataType;
 }
Пример #48
0
 public ValidatorParameter(string name, string paramValue, PropertyDataType dataType)
 {
     this._name       = name;
     this._paramValue = paramValue;
     this._dataType   = dataType;
 }
Пример #49
0
 public PropertyReference(string name, PropertyDataType propertyDataType)
 {
     if (name == null) throw new ArgumentNullException("name");
     PropertyName = name;
     Type = propertyDataType;
 }