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)); }
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))); }
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); }
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; }
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; }
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); }
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; }
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; }
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; }
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[] {}); } }
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; }