コード例 #1
0
        internal ChoCSVRecordConfiguration(Type recordType) : base(recordType)
        {
            CSVRecordFieldConfigurations = new List <ChoCSVRecordFieldConfiguration>();

            if (recordType != null)
            {
                Init(recordType);
            }

            if (Delimiter.IsNullOrEmpty())
            {
                if (Culture != null)
                {
                    Delimiter = Culture.TextInfo.ListSeparator;
                }

                if (Delimiter.IsNullOrWhiteSpace())
                {
                    Delimiter = ",";
                }
            }

            Sanitize            = false;
            InjectionChars      = "=@+-";
            InjectionEscapeChar = '\t';

            FileHeaderConfiguration = new ChoCSVFileHeaderConfiguration(recordType, Culture);
        }
コード例 #2
0
        public ChoCSVRecordConfiguration(Type recordType = null) : base(recordType)
        {
            RecordFieldConfigurations = new List <ChoCSVRecordFieldConfiguration>();

            if (recordType != null)
            {
                Init(recordType);
            }
            CSVFileHeaderConfiguration = new ChoCSVFileHeaderConfiguration(recordType, Culture);
        }
コード例 #3
0
        public ChoCSVRecordConfiguration(Type recordType = null) : base(recordType)
        {
            RecordFieldConfigurations = new List<ChoCSVRecordFieldConfiguration>();

            if (recordType != null)
            {
                Init(recordType);
            }

            if (Delimiter.IsNullOrEmpty())
            {
                if (Culture != null)
                    Delimiter = Culture.TextInfo.ListSeparator;

                if (Delimiter.IsNullOrWhiteSpace())
                    Delimiter = ",";
            }

            CSVFileHeaderConfiguration = new ChoCSVFileHeaderConfiguration(recordType, Culture);
        }
コード例 #4
0
        internal ChoCSVRecordConfiguration(Type recordType) : base(recordType)
        {
            CSVRecordFieldConfigurations = new List <ChoCSVRecordFieldConfiguration>();

            if (recordType != null)
            {
                Init(recordType);
            }

            if (Delimiter.IsNullOrEmpty())
            {
                if (Culture != null)
                {
                    Delimiter = Culture.TextInfo.ListSeparator;
                }

                if (Delimiter.IsNullOrWhiteSpace())
                {
                    Delimiter = ",";
                }
            }

            Sanitize            = false;
            InjectionChars      = "=@+-";
            InjectionEscapeChar = '\t';

            FileHeaderConfiguration = new ChoCSVFileHeaderConfiguration(recordType, Culture);
            RecordTypeConfiguration = new ChoCSVRecordTypeConfiguration();
            RecordTypeConfiguration.DefaultRecordType = recordType;

            RecordSelector = new Func <object, Type>((value) =>
            {
                Tuple <long, string> kvp = value as Tuple <long, string>;
                string line = kvp.Item2;
                if (line.IsNullOrEmpty())
                {
                    return(RecordTypeConfiguration.DefaultRecordType);
                }

                if (RecordTypeCodeExtractor != null)
                {
                    string rt = RecordTypeCodeExtractor(line);
                    return(RecordTypeConfiguration[rt]);
                }
                else
                {
                    if (RecordTypeConfiguration.Position <= 0)
                    {
                        return(RecordTypeConfiguration.DefaultRecordType);
                    }

                    string[] fieldValues = line.Split(Delimiter, StringSplitOptions, QuoteChar);
                    if (fieldValues.Length > 0 && RecordTypeConfiguration.Position - 1 < fieldValues.Length)
                    {
                        if (RecordTypeConfiguration.Contains(fieldValues[RecordTypeConfiguration.Position - 1]))
                        {
                            return(RecordTypeConfiguration[fieldValues[RecordTypeConfiguration.Position - 1]]);
                        }
                    }

                    return(RecordTypeConfiguration.DefaultRecordType);
                }
            });
        }