コード例 #1
0
        public ChoFixedLengthRecordWriter(Type recordType, ChoFixedLengthRecordConfiguration configuration) : base(recordType)
        {
            ChoGuard.ArgumentNotNull(configuration, "Configuration");
            Configuration = configuration;

            _callbackRecord = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordWrite>(recordType);
            _recBuffer      = new Lazy <List <object> >(() =>
            {
                if (Writer != null)
                {
                    var b = Writer.Context.RecBuffer;
                    if (b == null)
                    {
                        Writer.Context.RecBuffer = new List <object>();
                    }

                    return(Writer.Context.RecBuffer);
                }
                else
                {
                    return(new List <object>());
                }
            });

            //Configuration.Validate();
        }
コード例 #2
0
 public ChoCSVRecordReader(Type recordType, ChoCSVRecordConfiguration configuration) : base(recordType)
 {
     ChoGuard.ArgumentNotNull(configuration, "Configuration");
     Configuration   = configuration;
     _callbackRecord = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordRead>(recordType);
     //Configuration.Validate();
 }
コード例 #3
0
 public ChoCSVRecordReader(Type recordType, ChoCSVRecordConfiguration configuration) : base(recordType)
 {
     ChoGuard.ArgumentNotNull(configuration, "Configuration");
     Configuration               = configuration;
     _callbackRecord             = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordRead>(recordType);
     _customColumnMappableRecord = ChoMetadataObjectCache.CreateMetadataObject <IChoCustomColumnMappable>(recordType);
     _emptyLineReportableRecord  = ChoMetadataObjectCache.CreateMetadataObject <IChoEmptyLineReportable>(recordType);
     //Configuration.Validate();
 }
コード例 #4
0
        public ChoParquetRecordReader(Type recordType, ChoParquetRecordConfiguration configuration) : base(recordType, false)
        {
            ChoGuard.ArgumentNotNull(configuration, "Configuration");
            Configuration = configuration;

            _callbackRecordFieldRead     = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordFieldRead>(recordType);
            _callbackFileRead            = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyFileRead>(recordType);
            _callbackRecordRead          = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordRead>(recordType);
            _callbackRecordSeriablizable = ChoMetadataObjectCache.CreateMetadataObject <IChoRecordFieldSerializable>(recordType);
        }
コード例 #5
0
        public ChoAvroRecordReader(Type recordType, ChoAvroRecordConfiguration configuration) : base(recordType, false)
        {
            ChoGuard.ArgumentNotNull(configuration, "Configuration");
            Configuration = configuration;

            _callbackRecordFieldRead     = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordFieldRead>(recordType);
            _callbackFileRead            = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyFileRead>(recordType);
            _callbackRecordRead          = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordRead>(recordType);
            _callbackRecordSeriablizable = ChoMetadataObjectCache.CreateMetadataObject <IChoRecordFieldSerializable>(recordType);
            System.Threading.Thread.CurrentThread.CurrentCulture = Configuration.Culture;
        }
コード例 #6
0
 public ChoKVPRecordReader(Type recordType, ChoKVPRecordConfiguration configuration) : base(recordType)
 {
     ChoGuard.ArgumentNotNull(configuration, "Configuration");
     Configuration        = configuration;
     _callbackRecord      = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordRead>(recordType);
     _callbackFieldRecord = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordFieldRead>(recordType);
     if (_callbackFieldRecord == null)
     {
         _callbackFieldRecord = _callbackRecord;
     }
     _customKVPRecord = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyKVPRecordRead>(recordType);
     //Configuration.Validate();
 }
コード例 #7
0
        public ChoAvroRecordWriter(Type recordType, ChoAvroRecordConfiguration configuration) : base(recordType)
        {
            ChoGuard.ArgumentNotNull(configuration, "Configuration");
            Configuration = configuration;

            _callbackFileHeaderArrange = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyFileHeaderArrange>(recordType);
            _callbackRecordWrite       = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordWrite>(recordType);
            _callbackFileWrite         = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyFileWrite>(recordType);
            _callbackRecordFieldWrite  = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordFieldWrite>(recordType);
            System.Threading.Thread.CurrentThread.CurrentCulture = Configuration.Culture;

            _recBuffer = new Lazy <List <object> >(() =>
            {
                if (Writer != null)
                {
                    var b = Writer.Context.ContainsKey("RecBuffer") ? Writer.Context.RecBuffer : null;
                    if (b == null)
                    {
                        Writer.Context.RecBuffer = new List <object>();
                    }

                    return(Writer.Context.RecBuffer);
                }
                else
                {
                    return(new List <object>());
                }
            }, true);

            BeginWrite = new Lazy <bool>(() =>
            {
                if (_sw != null)
                {
                    return(RaiseBeginWrite(_sw));
                }
                if (_avroWriter != null)
                {
                    return(RaiseBeginWrite(_avroWriter));
                }

                return(false);
            });
            //Configuration.Validate();
        }
コード例 #8
0
        public override void Validate(object state)
        {
            base.Validate(state);

            if (NotifyRecordReadType != null)
            {
                NotifyFileReadObject        = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyFileRead>(NotifyRecordReadType);
                NotifyRecordReadObject      = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordRead>(NotifyRecordReadType);
                NotifyRecordFieldReadObject = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordFieldRead>(NotifyRecordReadType);
            }
            if (NotifyRecordWriteType != null)
            {
                NotifyRecordWriteObject = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordWrite>(NotifyRecordWriteType);
            }

            //if (SubRecordConfigurations.Count == 0)
            //    throw new ChoRecordConfigurationException("Atleast one record type must be registered.");

            foreach (Type t in SubRecordConfigurations.Keys)
            {
                if (SubRecordConfigurations[t] == null)
                {
                    throw new ChoRecordConfigurationException($"Missing record configuration for '{t.Name}' type.");
                }
            }

            if (RecordTypeConfiguration != null)
            {
                if (RecordSelector == null && RecordTypeCodeExtractor == null)
                {
                    if (RecordTypeConfiguration.StartIndex < 0)
                    {
                        throw new ChoRecordConfigurationException("RecordTypeConfiguration start index must be >= 0.");
                    }
                    else
                    {
                        if (RecordTypeConfiguration.Size <= 0)
                        {
                            throw new ChoRecordConfigurationException("RecordTypeConfiguration size must be > 0.");
                        }
                    }
                }
            }
        }
コード例 #9
0
        public ChoFixedLengthRecordWriter(Type recordType, ChoFixedLengthRecordConfiguration configuration) : base(recordType)
        {
            ChoGuard.ArgumentNotNull(configuration, "Configuration");
            Configuration = configuration;

            _callbackFileHeaderArrange = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyFileHeaderArrange>(recordType);
            _callbackFileHeaderWrite   = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyFileHeaderWrite>(recordType);
            _callbackRecordWrite       = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordWrite>(recordType);
            _callbackFileWrite         = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyFileWrite>(recordType);
            _callbackRecordFieldWrite  = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordFieldWrite>(recordType);

            _recBuffer = new Lazy <List <object> >(() =>
            {
                if (Writer != null)
                {
                    var b = Writer.Context.ContainsKey("RecBuffer") ? Writer.Context.RecBuffer : null;
                    if (b == null)
                    {
                        Writer.Context.RecBuffer = new List <object>();
                    }

                    return(Writer.Context.RecBuffer);
                }
                else
                {
                    return(new List <object>());
                }
            });

            BeginWrite = new Lazy <bool>(() =>
            {
                TextWriter sw = _sw as TextWriter;
                if (sw != null)
                {
                    return(RaiseBeginWrite(sw));
                }

                return(false);
            });
            //Configuration.Validate();
        }
コード例 #10
0
        public ChoYamlRecordWriter(Type recordType, ChoYamlRecordConfiguration configuration) : base(recordType, true)
        {
            ChoGuard.ArgumentNotNull(configuration, "Configuration");
            Configuration = configuration;

            _callbackRecordWrite         = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordWrite>(recordType);
            _callbackFileWrite           = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyFileWrite>(recordType);
            _callbackRecordFieldWrite    = ChoMetadataObjectCache.CreateMetadataObject <IChoNotifyRecordFieldWrite>(recordType);
            _callbackRecordSeriablizable = ChoMetadataObjectCache.CreateMetadataObject <IChoRecordFieldSerializable>(recordType);
            System.Threading.Thread.CurrentThread.CurrentCulture = Configuration.Culture;

            //_recBuffer = new Lazy<List<object>>(() =>
            //{
            //    if (Writer != null)
            //    {
            //        var b = Writer.Context.ContainsKey("RecBuffer") ? Writer.Context.RecBuffer : null;
            //        if (b == null)
            //            Writer.Context.RecBuffer = new List<object>();

            //        return Writer.Context.RecBuffer;
            //    }
            //    else
            //        return new List<object>();
            //}, true);

            //Configuration.Validate();

            BeginWrite = new Lazy <bool>(() =>
            {
                TextWriter sw = _sw as TextWriter;
                if (sw != null)
                {
                    return(RaiseBeginWrite(sw));
                }

                return(false);
            });
        }