Ejemplo n.º 1
0
        public ChoAvroWriter(string filePath, ChoBSONRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNullOrEmpty(filePath, "FilePath");

            Configuration = configuration;

            Init();

            _streamWriter         = new Lazy <StreamWriter>(() => new StreamWriter(ChoPath.GetFullPath(filePath), false, Configuration.Encoding, Configuration.BufferSize));
            _closeStreamOnDispose = true;
        }
Ejemplo n.º 2
0
        public ChoCSVReader(string filePath, ChoCSVRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNullOrEmpty(filePath, "FilePath");

            Configuration = configuration;

            Init();

            _textReader           = new StreamReader(ChoPath.GetFullPath(filePath), Configuration.GetEncoding(filePath), false, Configuration.BufferSize);
            _closeStreamOnDispose = true;
        }
Ejemplo n.º 3
0
        public ChoCSVReader <T> Load(string filePath)
        {
            ChoGuard.ArgumentNotNullOrEmpty(filePath, "FilePath");

            Close();
            Init();
            _textReader           = new StreamReader(ChoPath.GetFullPath(filePath), Configuration.GetEncoding(filePath), false, Configuration.BufferSize);
            _closeStreamOnDispose = true;

            return(this);
        }
Ejemplo n.º 4
0
        public ChoFixedLengthWriter(string filePath, ChoFixedLengthRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNullOrEmpty(filePath, "FilePath");

            Configuration = configuration;

            Init();

            _textWriter           = new StreamWriter(ChoPath.GetFullPath(filePath), false, Configuration.Encoding, Configuration.BufferSize);
            _closeStreamOnDispose = true;
        }
Ejemplo n.º 5
0
        public ChoXmlReader(string filePath, ChoXmlRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNullOrEmpty(filePath, "FilePath");

            Configuration = configuration;

            Init();

            _xmlReader = XmlReader.Create(new StreamReader(ChoPath.GetFullPath(filePath), Configuration.GetEncoding(filePath), false, Configuration.BufferSize),
                                          new XmlReaderSettings(), new XmlParserContext(null, Configuration.NamespaceManager, null, XmlSpace.None));
            _closeStreamOnDispose = true;
        }
Ejemplo n.º 6
0
        public ChoCSVReader(string filePath, ChoCSVRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNullOrEmpty(filePath, "FilePath");

            TraceSwitch   = ChoETLFramework.TraceSwitch;
            Configuration = configuration;

            Init();

            _streamReader         = new StreamReader(ChoPath.GetFullPath(filePath), Configuration.Encoding, false, Configuration.BufferSize);
            _closeStreamOnDispose = true;
        }
Ejemplo n.º 7
0
        public ChoXmlReader(string filePath, string defaultNamespace, ChoXmlRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNullOrEmpty(filePath, "FilePath");

            Configuration = configuration;
            Init();
            if (!defaultNamespace.IsNullOrWhiteSpace())
            {
                Configuration.NamespaceManager.AddNamespace("", defaultNamespace);
            }


            _sr = new StreamReader(ChoPath.GetFullPath(filePath), Configuration.GetEncoding(filePath), false, Configuration.BufferSize);
            //InitXml();
            _closeStreamOnDispose = true;
        }
Ejemplo n.º 8
0
        public static string[] ReadAllLines(string filePath)
        {
            ChoGuard.ArgumentNotNullOrEmpty(filePath, "FilePath");
            filePath = ChoPath.GetFullPath(filePath);

            if (File.Exists(filePath))
            {
                return(File.ReadAllLines(filePath));
            }
            else
            {
                try
                {
                    File.CreateText(filePath);
                }
                catch { }
                return(new string[] {});
            }
        }
Ejemplo n.º 9
0
        public ChoXmlReader(string filePath, string defaultNamespace)
        {
            ChoGuard.ArgumentNotNullOrEmpty(filePath, "FilePath");

            Configuration = new ChoXmlRecordConfiguration();
            if (!defaultNamespace.IsNullOrWhiteSpace())
            {
                Configuration.NamespaceManager.AddNamespace("", defaultNamespace);
            }

            Init();

            _sr        = new StreamReader(ChoPath.GetFullPath(filePath), Configuration.GetEncoding(filePath), false, Configuration.BufferSize);
            _xmlReader = XmlReader.Create(_sr,
                                          new XmlReaderSettings()
            {
                DtdProcessing = DtdProcessing.Ignore, XmlResolver = null
            }, new XmlParserContext(null, Configuration.NamespaceManager, null, XmlSpace.None));
            _closeStreamOnDispose = true;
        }