public EnumTagField(TagFieldDataContract fieldDataContract) : base(fieldDataContract) { if (fieldDataContract.Values == null || !fieldDataContract.Values.Any()) { throw new ArgumentOutOfRangeException("Empty enum is useless"); } _values = fieldDataContract.Values; }
public static IntTagField CreateIntField() { var fieldDataContract = new TagFieldDataContract { Name = IntFieldName, Type = TagFieldConstants.Int }; return(new IntTagField(fieldDataContract)); }
public static TimeTagField CreateTimeField() { var fieldDataContract = new TagFieldDataContract { Name = TimeFieldName, Type = TagFieldConstants.Time }; return(new TimeTagField(fieldDataContract)); }
public static DateTagField CreateDateField() { var fieldDataContract = new TagFieldDataContract { Name = DateFieldName, Type = TagFieldConstants.Date }; return(new DateTagField(fieldDataContract)); }
public static StringTagField CreateStringField() { var fieldDataContract = new TagFieldDataContract { Name = StringFieldName, Type = TagFieldConstants.String }; return(new StringTagField(fieldDataContract)); }
public static FloatTagField CreateFloatField() { var fieldDataContract = new TagFieldDataContract { Name = FloatFieldName, Type = TagFieldConstants.Float }; return(new FloatTagField(fieldDataContract)); }
public static EnumTagField CreateEnumField() { var fieldDataContract = new TagFieldDataContract { Name = EnumFieldName, Type = TagFieldConstants.Enum, Values = new List <string> { EnumValueA, EnumValueB } }; return(new EnumTagField(fieldDataContract)); }
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); } }
public BaseTagField(TagFieldDataContract tagFieldDataContract) { _name = tagFieldDataContract.Name; }
public TimeTagField(TagFieldDataContract fieldDataContract) : base(fieldDataContract) { }
public StringTagField(TagFieldDataContract fieldDataContract) : base(fieldDataContract) { }
public FloatTagField(TagFieldDataContract fieldDataContract) : base(fieldDataContract) { }