示例#1
0
 public EnumTagField(TagFieldDataContract fieldDataContract)
     : base(fieldDataContract)
 {
     if (fieldDataContract.Values == null || !fieldDataContract.Values.Any())
     {
         throw new ArgumentOutOfRangeException("Empty enum is useless");
     }
     _values = fieldDataContract.Values;
 }
示例#2
0
文件: Helpers.cs 项目: Emettant/hutel
        public static IntTagField CreateIntField()
        {
            var fieldDataContract = new TagFieldDataContract
            {
                Name = IntFieldName,
                Type = TagFieldConstants.Int
            };

            return(new IntTagField(fieldDataContract));
        }
示例#3
0
文件: Helpers.cs 项目: Emettant/hutel
        public static TimeTagField CreateTimeField()
        {
            var fieldDataContract = new TagFieldDataContract
            {
                Name = TimeFieldName,
                Type = TagFieldConstants.Time
            };

            return(new TimeTagField(fieldDataContract));
        }
示例#4
0
文件: Helpers.cs 项目: Emettant/hutel
        public static DateTagField CreateDateField()
        {
            var fieldDataContract = new TagFieldDataContract
            {
                Name = DateFieldName,
                Type = TagFieldConstants.Date
            };

            return(new DateTagField(fieldDataContract));
        }
示例#5
0
文件: Helpers.cs 项目: Emettant/hutel
        public static StringTagField CreateStringField()
        {
            var fieldDataContract = new TagFieldDataContract
            {
                Name = StringFieldName,
                Type = TagFieldConstants.String
            };

            return(new StringTagField(fieldDataContract));
        }
示例#6
0
文件: Helpers.cs 项目: Emettant/hutel
        public static FloatTagField CreateFloatField()
        {
            var fieldDataContract = new TagFieldDataContract
            {
                Name = FloatFieldName,
                Type = TagFieldConstants.Float
            };

            return(new FloatTagField(fieldDataContract));
        }
示例#7
0
文件: Helpers.cs 项目: Emettant/hutel
        public static EnumTagField CreateEnumField()
        {
            var fieldDataContract = new TagFieldDataContract
            {
                Name   = EnumFieldName,
                Type   = TagFieldConstants.Enum,
                Values = new List <string> {
                    EnumValueA, EnumValueB
                }
            };

            return(new EnumTagField(fieldDataContract));
        }
示例#8
0
        public static BaseTagField FromDataContract(TagFieldDataContract fieldDataContract)
        {
            if (fieldDataContract.Name == string.Empty)
            {
                throw new TagValidationException("Field name is empty");
            }
            Type type;

            if (!StringToFieldType.TryGetValue(fieldDataContract.Type, out type))
            {
                throw new TagValidationException(
                          $"Unknown type {fieldDataContract.Type} in tag field {fieldDataContract.Name}");
            }
            try
            {
                return((BaseTagField)Activator.CreateInstance(type, fieldDataContract));
            }
            catch (Exception ex)
            {
                throw new TagValidationException(
                          $"Cannot initialize field {fieldDataContract.Name}", ex);
            }
        }
示例#9
0
 public BaseTagField(TagFieldDataContract tagFieldDataContract)
 {
     _name = tagFieldDataContract.Name;
 }
示例#10
0
 public TimeTagField(TagFieldDataContract fieldDataContract) : base(fieldDataContract)
 {
 }
示例#11
0
 public StringTagField(TagFieldDataContract fieldDataContract) : base(fieldDataContract)
 {
 }
示例#12
0
 public FloatTagField(TagFieldDataContract fieldDataContract) : base(fieldDataContract)
 {
 }