コード例 #1
0
ファイル: ChoObjectEx.cs プロジェクト: xman086/ChoETL
        public static void JsonSerialize(string path, object target, Encoding encoding = null)
        {
            ChoGuard.ArgumentNotNullOrEmpty(path, "Path");
            ChoGuard.ArgumentNotNull(target, "Target");

            Directory.CreateDirectory(Path.GetDirectoryName(ChoPath.GetFullPath(path)));

            File.WriteAllText(path, JsonSerialize(target, encoding));
        }
コード例 #2
0
ファイル: ChoIniFile.cs プロジェクト: JavierCanon/Dalayer.net
        private string GetFullPath(string path)
        {
            if (Path.IsPathRooted(path))
            {
                return(path);
            }

            path = ChoPath.GetFullPath(path, ChoETLFrxBootstrap.ConfigDirectory);
            return(Path.Combine(Path.Combine(Path.GetDirectoryName(path), "Config"), Path.GetFileName(path)));
        }
コード例 #3
0
        protected override string Write(IEnumerable <T> run)
        {
            var file = ChoPath.GetTempFileName();

            using (var writer = new FileStream(file, FileMode.Create, FileAccess.Write, FileShare.None))
            {
                new BinaryFormatter().Serialize(writer, run.ToArray());
            }
            return(file);
        }
コード例 #4
0
        public ChoFixedLengthReader(string filePath, ChoFixedLengthRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNullOrEmpty(filePath, "FilePath");

            Configuration = configuration;

            Init();

            _textReader           = new StreamReader(ChoPath.GetFullPath(filePath), Configuration.GetEncoding(filePath), false, Configuration.BufferSize);
            _closeStreamOnDispose = true;
        }
コード例 #5
0
ファイル: ChoCSVWriter.cs プロジェクト: shivanan/ChoETL
        public ChoCSVWriter(string filePath, ChoCSVRecordConfiguration configuration = null)
        {
            ChoGuard.ArgumentNotNullOrEmpty(filePath, "FilePath");

            Configuration = configuration;

            Init();

            _textWriter           = new StreamWriter(ChoPath.GetFullPath(filePath), false, Configuration.Encoding, Configuration.BufferSize);
            _closeStreamOnDispose = true;
        }
コード例 #6
0
ファイル: ChoJSONReader.cs プロジェクト: ywscr/ChoETL
        public ChoJSONReader <T> Load(string filePath)
        {
            ChoGuard.ArgumentNotNullOrEmpty(filePath, "FilePath");

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

            return(this);
        }
コード例 #7
0
ファイル: ChoXmlReader.cs プロジェクト: ScottColson/ChoETL
        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;
        }
コード例 #8
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;
        }
コード例 #9
0
ファイル: ChoXmlReader.cs プロジェクト: naveenpothana/ChoETL
        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;
        }
コード例 #10
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[] {});
            }
        }
コード例 #11
0
ファイル: ChoXmlReader.cs プロジェクト: zhongshuiyuan/ChoETL
        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;
        }