Exemple #1
0
        public ChoManifoldRecordConfiguration() : base(typeof(object))
        {
            FileHeaderConfiguration = new ChoManifoldFileHeaderConfiguration(Culture);
            RecordTypeConfiguration = new ChoManifoldRecordTypeConfiguration();
            _recordSelecter         = new Func <string, Type>((line) =>
            {
                if (line.IsNullOrEmpty())
                {
                    return(null);
                }

                if (_recordTypeCodeExtractor != null)
                {
                    string rt = _recordTypeCodeExtractor(line);
                    return(RecordTypeConfiguration[rt]);
                }
                else
                {
                    if (RecordTypeConfiguration.StartIndex >= 0 && RecordTypeConfiguration.Size == 0)
                    {
                        return(null);
                    }
                    if (RecordTypeConfiguration.StartIndex + RecordTypeConfiguration.Size > line.Length)
                    {
                        return(null);
                    }

                    return(RecordTypeConfiguration[line.Substring(RecordTypeConfiguration.StartIndex, RecordTypeConfiguration.Size)]);
                }
            });
        }
Exemple #2
0
        public ChoManifoldRecordConfiguration() : base(typeof(object))
        {
            FileHeaderConfiguration = new ChoManifoldFileHeaderConfiguration(Culture);
            RecordTypeConfiguration = new ChoManifoldRecordTypeConfiguration();

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

                if (RecordTypeCodeExtractor != null)
                {
                    string rt = RecordTypeCodeExtractor(line);
                    if (RecordTypeConfiguration.Contains(rt))
                    {
                        return(RecordTypeConfiguration[rt]);
                    }
                }
                else
                {
                    if (RecordTypeConfiguration.StartIndex >= 0 && RecordTypeConfiguration.Size == 0)
                    {
                        return(RecordTypeConfiguration.DefaultRecordType);
                    }
                    if (RecordTypeConfiguration.StartIndex + RecordTypeConfiguration.Size > line.Length)
                    {
                        return(RecordTypeConfiguration.DefaultRecordType);
                    }

                    string rtc = line.Substring(RecordTypeConfiguration.StartIndex, RecordTypeConfiguration.Size);
                    if (RecordTypeConfiguration.Contains(rtc))
                    {
                        return(RecordTypeConfiguration[rtc]);
                    }
                }

                return(RecordTypeConfiguration.DefaultRecordType);
            });
        }