Ejemplo n.º 1
0
        protected override void Init(Type recordType)
        {
            base.Init(recordType);

            ChoFileRecordObjectAttribute recObjAttr = ChoType.GetAttribute <ChoFileRecordObjectAttribute>(recordType);

            if (recObjAttr != null)
            {
                if (recObjAttr.BufferSize > 0)
                {
                    BufferSize = recObjAttr.BufferSize;
                }
                if (recObjAttr.Comments.IsNullOrWhiteSpace())
                {
                    Comments = new string[] { }
                }
                ;
                else
                {
                    Comments = recObjAttr.Comments.SplitNTrim(',');
                }
                Culture            = recObjAttr.Culture;
                EOLDelimiter       = recObjAttr.EOLDelimiter;
                IgnoreEmptyLine    = recObjAttr.IgnoreEmptyLine;
                ColumnCountStrict  = recObjAttr.ColumnCountStrict;
                ColumnOrderStrict  = recObjAttr.ColumnOrderStrict;
                QuoteChar          = recObjAttr.QuoteChar;
                QuoteAllFields     = recObjAttr.QuoteAllFields;
                StringSplitOptions = recObjAttr.StringSplitOptions;
                if (!recObjAttr.Encoding.IsNullOrWhiteSpace())
                {
                    Encoding = Encoding.GetEncoding(recObjAttr.Encoding);
                }
            }
        }
Ejemplo n.º 2
0
        protected virtual void Init(Type recordType)
        {
            ChoFileRecordObjectAttribute recObjAttr = ChoType.GetAttribute <ChoFileRecordObjectAttribute>(recordType);

            if (recObjAttr != null)
            {
                ErrorMode            = recObjAttr.ErrorMode;
                IgnoreFieldValueMode = recObjAttr.IgnoreFieldValueMode;
                if (recObjAttr.BufferSize > 0)
                {
                    BufferSize = recObjAttr.BufferSize;
                }
                if (recObjAttr.Comments.IsNullOrWhiteSpace())
                {
                    Comments = new string[] { }
                }
                ;
                else
                {
                    Comments = recObjAttr.Comments.SplitNTrim(',');
                }
                Culture            = recObjAttr.Culture;
                EOLDelimiter       = recObjAttr.EOLDelimiter;
                IgnoreEmptyLine    = recObjAttr.IgnoreEmptyLine;
                ColumnCountStrict  = recObjAttr.ColumnCountStrict;
                QuoteChar          = recObjAttr.QuoteChar;
                QuoteAllFields     = recObjAttr.QuoteAllFields;
                StringSplitOptions = recObjAttr.StringSplitOptions;
                Encoding           = recObjAttr.Encoding.CastTo <Encoding>(Encoding);
            }
        }
Ejemplo n.º 3
0
        protected override void Init(Type recordType)
        {
            base.Init(recordType);

            if (recordType == null)
            {
                return;
            }

            ChoFileRecordObjectAttribute recObjAttr = ChoType.GetAttribute <ChoFileRecordObjectAttribute>(recordType);

            if (recObjAttr != null)
            {
                AutoDiscoverFieldTypes = true;
                MaxScanRows            = 0;
                if (recObjAttr.BufferSize > 0)
                {
                    BufferSize = recObjAttr.BufferSize;
                }
                if (recObjAttr.Comments.IsNullOrWhiteSpace())
                {
                    Comments = new string[] { }
                }
                ;
                else
                {
                    Comments = recObjAttr.Comments.SplitNTrim(',');
                }
                Culture            = recObjAttr.Culture;
                EOLDelimiter       = recObjAttr.EOLDelimiter;
                IgnoreEmptyLine    = recObjAttr.IgnoreEmptyLine;
                ColumnCountStrict  = recObjAttr.ColumnCountStrict;
                ColumnOrderStrict  = recObjAttr.ColumnOrderStrict;
                QuoteChar          = recObjAttr.QuoteChar;
                QuoteAllFields     = recObjAttr.QuoteAllFields;
                StringSplitOptions = recObjAttr.StringSplitOptions;
                if (!recObjAttr.Encoding.IsNullOrWhiteSpace())
                {
                    Encoding = Encoding.GetEncoding(recObjAttr.Encoding);
                }
                TreatCurrencyAsDecimal = recObjAttr.TreatCurrencyAsDecimal;
                NullValue = recObjAttr.NullValue;
            }
        }
Ejemplo n.º 4
0
        private ChoFileRecordConfiguration GetConfiguration(Type recordType)
        {
            ChoFileRecordConfiguration config = Configuration[recordType];

            if (config == null)
            {
                ChoFileRecordObjectAttribute recObjAttr = ChoType.GetAttribute <ChoFileRecordObjectAttribute>(recordType);
                if (recObjAttr == null || recObjAttr is ChoCSVRecordObjectAttribute)
                {
                    Configuration[recordType] = new ChoCSVRecordConfiguration(recordType);
                }
                else if (recObjAttr is ChoFixedLengthRecordObjectAttribute)
                {
                    Configuration[recordType] = new ChoFixedLengthRecordConfiguration(recordType);
                }
            }

            return(Configuration[recordType]);
        }