Esempio n. 1
0
        public static ChoFixedLengthReader <T> LoadText(string inputText, Encoding encoding = null, ChoFixedLengthRecordConfiguration configuration = null, TraceSwitch traceSwitch = null)
        {
            var r = new ChoFixedLengthReader <T>(inputText.ToStream(encoding), configuration)
            {
                TraceSwitch = traceSwitch == null ? ChoETLFramework.TraceSwitch : traceSwitch
            };

            r._closeStreamOnDispose = true;

            return(r);
        }
Esempio n. 2
0
        internal static IEnumerator <object> LoadText(Type recType, string inputText, ChoFixedLengthRecordConfiguration configuration, Encoding encoding, int bufferSize, TraceSwitch traceSwitch = null)
        {
            ChoFixedLengthRecordReader rr = new ChoFixedLengthRecordReader(recType, configuration);

            rr.TraceSwitch = traceSwitch == null ? ChoETLFramework.TraceSwitchOff : traceSwitch;
            return(rr.AsEnumerable(new StreamReader(inputText.ToStream(), encoding, false, bufferSize)).GetEnumerator());
        }
Esempio n. 3
0
        public static ChoFixedLengthReader <T> LoadLines(IEnumerable <string> inputLines, ChoFixedLengthRecordConfiguration configuration = null, TraceSwitch traceSwitch = null)
        {
            var r = new ChoFixedLengthReader <T>(inputLines, configuration)
            {
                TraceSwitch = traceSwitch == null ? ChoETLFramework.TraceSwitch : traceSwitch
            };

            r._closeStreamOnDispose = true;

            return(r);
        }
Esempio n. 4
0
 public ChoFixedLengthWriter(ChoFixedLengthRecordConfiguration configuration = null)
 {
     Configuration = configuration;
 }
Esempio n. 5
0
 public static string ToText <TRec>(TRec record, ChoFixedLengthRecordConfiguration configuration = null, TraceSwitch traceSwitch = null)
     where TRec : class
 {
     return(ToTextAll(ChoEnumerable.AsEnumerable <TRec>(record), configuration, traceSwitch));
 }
 internal void Validate(ChoFixedLengthRecordConfiguration config)
 {
     try
     {
         if (FieldName.IsNullOrWhiteSpace())
         {
             FieldName = Name;
         }
         if (StartIndex < 0)
         {
             throw new ChoRecordConfigurationException("StartIndex must be > 0.");
         }
         if (Size == null || Size.Value < 0)
         {
             throw new ChoRecordConfigurationException("Size must be > 0.");
         }
         if (FillChar != null)
         {
             if (FillChar.Value == ChoCharEx.NUL)
             {
                 throw new ChoRecordConfigurationException("Invalid '{0}' FillChar specified.".FormatString(FillChar));
             }
             if (config.EOLDelimiter.Contains(FillChar.Value))
             {
                 throw new ChoRecordConfigurationException("FillChar [{0}] can't be one EOLDelimiter characters [{1}]".FormatString(FillChar, config.EOLDelimiter));
             }
         }
         if (config.Comments != null)
         {
             if ((from comm in config.Comments
                  where comm.Contains(FillChar.ToNString(' '))
                  select comm).Any())
             {
                 throw new ChoRecordConfigurationException("One of the Comments contains FillChar. Not allowed.");
             }
             if ((from comm in config.Comments
                  where comm.Contains(config.EOLDelimiter)
                  select comm).Any())
             {
                 throw new ChoRecordConfigurationException("One of the Comments contains EOLDelimiter. Not allowed.");
             }
         }
         if (Size != null && Size.Value <= 0)
         {
             throw new ChoRecordConfigurationException("Size must be > 0.");
         }
         if (ErrorMode == null)
         {
             ErrorMode = ChoErrorMode.ReportAndContinue; // config.ErrorMode;
         }
         if (IgnoreFieldValueMode == null)
         {
             IgnoreFieldValueMode = config.IgnoreFieldValueMode;
         }
         if (QuoteField == null)
         {
             QuoteField = config.QuoteAllFields;
         }
     }
     catch (Exception ex)
     {
         throw new ChoRecordConfigurationException("Invalid configuration found at '{0}' field.".FormatString(Name), ex);
     }
 }
Esempio n. 7
0
 public ChoFixedLengthWriter(StringBuilder sb, ChoFixedLengthRecordConfiguration configuration = null) : this(new StringWriter(sb), configuration)
 {
 }