private string _replaceExtension(string path, BplFormat format) { if (path.IsEmpty()) return ""; path = Path.Combine(Path.GetDirectoryName(path), Path.GetFileNameWithoutExtension(path)); switch (format) { case BplFormat.Xml: return path + ".xml"; case BplFormat.Json: case BplFormat.Json_t: return path + ".js"; case BplFormat.Binary: return path + ".bin"; default: return path; } }
private BplDocumentParser _invokeParser(BplFormat format, string input) { BplDocumentParser parser = null; switch (format) { case BplFormat.Xml: parser = new BplXmlParser { PreserveErrorsInfo = true }; break; case BplFormat.Json: parser = new BplJsonParser { PreserveErrorsInfo = true, StronglyTyped = false }; break; case BplFormat.Json_t: parser = new BplJsonParser { PreserveErrorsInfo = true, StronglyTyped = true }; break; case BplFormat.Binary: parser = new BplHexParser { }; break; default: return null; } if (parser != null) { parser.Parse(input); } return parser; }
private BplDocumentFormatter _invokeFormatter(BplFormat format, BplObject input) { BplDocumentFormatter formatter = null; switch (format) { case BplFormat.Xml: formatter = new BplXmlFormatter { PrettyPrint = true }; break; case BplFormat.Json: formatter = new BplJsonFormatter { PrettyPrint = true, StronglyTyped = false }; break; case BplFormat.Json_t: formatter = new BplJsonFormatter { PrettyPrint = true, StronglyTyped = true }; break; case BplFormat.Binary: formatter = new BplHexFormatter { }; break; default: return null; } if (formatter != null) { formatter.Format(input); } return formatter; }
private static string _toFormatName(BplFormat format) { switch (format) { case BplFormat.Xml: return "Xml Format"; case BplFormat.Json: return "Json Format"; case BplFormat.Json_t: return "Json-T Format"; case BplFormat.Binary: return "Binary Format"; default: return "Unknown Format"; } }