public static CodeBook GetCodeBookType(FileStructureProfile source)
 {
     return(new CodeBook()
     {
         CodeBookName = source.FieldNameKey
     });
 }
        public static Identifier GetIdentifierType(FileStructureProfile source)
        {
            int maxlength = int.Parse(source.MaxLength);

            int.TryParse(source.MinLength, out var minLength);
            return(new Identifier(minLength, maxlength));
        }
        public static ReferenceLinkExtended GetReferenceLinkExtendedType(FileStructureProfile source)
        {
            int maxlength = int.Parse(source.MaxLength);

            int.TryParse(source.MinLength, out var minLength);
            return(new ReferenceLinkExtended(minLength, maxlength));
        }
Exemplo n.º 4
0
        public void DecimalNumberType_FromProfilerTest()
        {
            FileStructureProfile source = this.GetProfileForDecimal();
            BaseValidator        field  = source.ValidatorFieldBuilder();

            bool flag = field is DecimalNumber;

            Assert.True(flag);
        }
        public void DateAndTimeFromBuilderFailedTest(string value, bool isNullable)
        {
            FileStructureProfile source = this.GetProfileForDateAndTime(isNullable);
            BaseValidator        field  = source.ValidatorFieldBuilder();

            field.Value = value;
            bool isValid = field.IsValid;

            Assert.False(isValid);
        }
Exemplo n.º 6
0
        public void DecimalNumber_FromProfiler_PassedTest(string value)
        {
            FileStructureProfile source = this.GetProfileForDecimal();
            BaseValidator        field  = source.ValidatorFieldBuilder();

            field.Value = value;

            bool flag = field.IsValid;

            Assert.True(flag);
        }
        public static BaseValidator ValidatorFieldBuilder(this FileStructureProfile source)
        {
            BaseValidator target     = null;
            Type          sourceType = GetTypeByName(source.FieldType);

            if (sourceType == typeof(Identifier))
            {
                target            = GetIdentifierType(source);
                target.IsNullable = !string.IsNullOrEmpty(source.IsNullable) && source.IsNullable.ToUpper().Equals("Y")
                    ? true
                    : false;
            }
            else if (sourceType == typeof(IdentifierExtended))
            {
                target            = GetIdentifierExtendedType(source);
                target.IsNullable = !string.IsNullOrEmpty(source.IsNullable) && source.IsNullable.ToUpper().Equals("Y")
                    ? true
                    : false;
            }
            else if (sourceType == typeof(DecimalNumber))
            {
                target            = GetDecimalNumberType(source);
                target.IsNullable = !string.IsNullOrEmpty(source.IsNullable) && source.IsNullable.ToUpper().Equals("Y")
                    ? true
                    : false;
            }
            else if (sourceType == typeof(IntegerNumber))
            {
                target            = GetIntegerNumberType(source);
                target.IsNullable = !string.IsNullOrEmpty(source.IsNullable) && source.IsNullable.ToUpper().Equals("Y")
                    ? true
                    : false;
            }
            else if (sourceType == typeof(DateAndTime))
            {
                target            = GetDateAndTimeType(source);
                target.IsNullable = !string.IsNullOrEmpty(source.IsNullable) && source.IsNullable.ToUpper().Equals("Y")
                    ? true
                    : false;
            }
            else if (sourceType == typeof(Date))
            {
                target            = GetDateType(source);
                target.IsNullable = !string.IsNullOrEmpty(source.IsNullable) && source.IsNullable.ToUpper().Equals("Y")
                    ? true
                    : false;
            }
            else if (sourceType == typeof(Text))
            {
                target            = GetTextType(source);
                target.IsNullable = !string.IsNullOrEmpty(source.IsNullable) && source.IsNullable.ToUpper().Equals("Y")
                    ? true
                    : false;
            }
            else if (sourceType == typeof(CodeBook))
            {
                target = GetCodeBookType(source);
            }
            else if (sourceType == typeof(ReferenceLink))
            {
                target = GetReferenceLinkType(source);
            }
            else if (sourceType == typeof(ReferenceLinkExtended))
            {
                target = GetReferenceLinkExtendedType(source);
            }
            else
            {
                throw new ArgumentException($"Unknown field type [{source.FieldName}-{source.FieldName}]");
                //target = new Text(string.Empty, "100");
            }

            return(target);
        }
 public static Text GetTextType(FileStructureProfile source)
 {
     return(new Text(source.MinLength, source.MaxLength));
 }
 public static IntegerNumber GetIntegerNumberType(FileStructureProfile source)
 {
     return(new IntegerNumber());
 }
 public static DecimalNumber GetDecimalNumberType(FileStructureProfile source)
 {
     return(new DecimalNumber(source.DomainType));
 }
 public static Date GetDateType(FileStructureProfile source)
 {
     return(new Date());
 }