public static void BinaryToTree(String BinaryPath, String TreePath, String MainType) { var TypeName = ObjectSchemaExtensions.GetDotNetFullNameFromVersionedName(MainType); var a = SchemaAssembly(); var t = a.GetType(TypeName); if (t == null) { throw new InvalidOperationException("TypeNotExist: " + TypeName); } var tbc = TreeBinaryConverter(); Byte[] Data; using (var s = Streams.OpenReadable(BinaryPath)) { Data = s.Read((int)(s.Length)); } var x = tbc.BinaryToTree(t, Data); var Dir = FileNameHandling.GetFileDirectory(TreePath); if (Dir != "" && !Directory.Exists(Dir)) { Directory.CreateDirectory(Dir); } TreeFile.WriteFile(TreePath, x); }
public static void JsonToTree(String JsonPath, String TreePath) { var xs = new XmlSerializer(true); var t = Txt.ReadFile(JsonPath); var j = Niveum.Json.JToken.Parse(t); var o = World.Json.JsonTranslator.WorldFromJson(j); var x = xs.Write <World.World>(o); TreeFile.WriteFile(TreePath, x); }
public static void BinaryToTreeWithFirefly(String BinaryPath, String TreePath) { var tbc = new TreeBinaryConverter(); Byte[] Data; using (var s = Streams.OpenReadable(BinaryPath)) { Data = s.Read((int)(s.Length)); } var x = tbc.BinaryToTree <World.World>(Data); TreeFile.WriteFile(TreePath, x); }
private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e) { c.IP = TextBox_IP.Text; c.Port = NumericStrings.InvariantParseInt32(TextBox_Port.Text); c.Mode = GetMode(); var x = (new XmlSerializer()).Write(c); try { TreeFile.WriteFile(ConfigurationFilePath, x); } catch { } }
public static void BinaryToTree(String BinaryPath, String TreePath) { Byte[] b; using (var s = Streams.OpenReadable(BinaryPath)) { b = s.Read((int)(s.Length)); } World.World o; using (var s = new World.BinaryWithoutFirefly.ByteArrayStream()) { s.WriteBytes(b); s.Position = 0; o = World.BinaryWithoutFirefly.BinaryTranslator.WorldFromBinary(s); } var xs = new XmlSerializer(true); var x = xs.Write <World.World>(o); TreeFile.WriteFile(TreePath, x); }
public static int MainInner() { TextEncoding.WritingDefault = TextEncoding.UTF8; var CmdLine = CommandLine.GetCmdLine(); var argv = CmdLine.Arguments; if (CmdLine.Arguments.Length != 0) { DisplayInfo(); return(-1); } if (CmdLine.Options.Length == 0) { DisplayInfo(); return(0); } var xs = new XmlSerializer(); foreach (var opt in CmdLine.Options) { var optNameLower = opt.Name.ToLower(); if ((optNameLower == "?") || (optNameLower == "help")) { DisplayInfo(); return(0); } else if (optNameLower == "load") { var args = opt.Arguments; if (args.Length == 1) { var CookedRelationSchemaPath = args[0]; InvalidateSchema(); rsl.LoadSchema(CookedRelationSchemaPath); } else { DisplayInfo(); return(-1); } } else if (optNameLower == "save") { var args = opt.Arguments; if (args.Length == 1) { var CookedRelationSchemaPath = args[0]; var s = GetRelationSchema(); var x = xs.Write(s); TreeFile.WriteFile(CookedRelationSchemaPath, x); } else { DisplayInfo(); return(-1); } } else if (optNameLower == "loadtyperef") { var args = opt.Arguments; if (args.Length == 1) { var SchemaPath = args[0]; if (Directory.Exists(SchemaPath)) { foreach (var f in Directory.GetFiles(SchemaPath, "*.tree", SearchOption.AllDirectories).OrderBy(s => s, StringComparer.OrdinalIgnoreCase)) { InvalidateSchema(); rsl.LoadTypeRef(f); } } else { InvalidateSchema(); rsl.LoadTypeRef(SchemaPath); } } else { DisplayInfo(); return(-1); } } else if (optNameLower == "loadtype") { var args = opt.Arguments; if (args.Length == 1) { var SchemaPath = args[0]; if (Directory.Exists(SchemaPath)) { foreach (var f in Directory.GetFiles(SchemaPath, "*.tree", SearchOption.AllDirectories).OrderBy(s => s, StringComparer.OrdinalIgnoreCase)) { InvalidateSchema(); rsl.LoadType(f); } } else { InvalidateSchema(); rsl.LoadType(SchemaPath); } } else { DisplayInfo(); return(-1); } } else if (optNameLower == "import") { var args = opt.Arguments; if (args.Length == 1) { rsl.AddImport(args[0]); } else { DisplayInfo(); return(-1); } } else if (optNameLower == "t2tsql") { var args = opt.Arguments; if (args.Length == 2) { RelationSchemaToTSqlCode(args[0], args[1]); } else { DisplayInfo(); return(-1); } } else if (optNameLower == "t2mysql") { var args = opt.Arguments; if (args.Length == 2) { RelationSchemaToMySqlCode(args[0], args[1]); } else { DisplayInfo(); return(-1); } } else if (optNameLower == "t2cse") { var args = opt.Arguments; if (args.Length == 5) { RelationSchemaToCSharpLinqToEntitiesCode(args[0], args[1], args[2], args[3], args[4]); } else { DisplayInfo(); return(-1); } } else if (optNameLower == "t2csdp") { var args = opt.Arguments; if (args.Length == 2) { RelationSchemaToCSharpDatabasePlainCode(args[0], args[1], true); } else if (args.Length == 3) { RelationSchemaToCSharpDatabasePlainCode(args[0], args[1], Boolean.Parse(args[2])); } else { DisplayInfo(); return(-1); } } else if (optNameLower == "t2csm") { var args = opt.Arguments; if (args.Length == 3) { RelationSchemaToCSharpMemoryCode(args[0], args[1], args[2]); } else { DisplayInfo(); return(-1); } } else if (optNameLower == "t2csmssql") { var args = opt.Arguments; if (args.Length == 3) { RelationSchemaToCSharpSqlServerCode(args[0], args[1], args[2]); } else { DisplayInfo(); return(-1); } } else if (optNameLower == "t2csmysql") { var args = opt.Arguments; if (args.Length == 3) { RelationSchemaToCSharpMySqlCode(args[0], args[1], args[2]); } else { DisplayInfo(); return(-1); } } else if (optNameLower == "t2cskrs") { var args = opt.Arguments; if (args.Length == 3) { RelationSchemaToCSharpKrustallosCode(args[0], args[1], args[2]); } else { DisplayInfo(); return(-1); } } else if (optNameLower == "t2cscw") { var args = opt.Arguments; if (args.Length == 3) { RelationSchemaToCSharpCountedCode(args[0], args[1], args[2]); } else { DisplayInfo(); return(-1); } } else if (optNameLower == "t2cppdp") { var args = opt.Arguments; if (args.Length == 2) { RelationSchemaToCppDatabasePlainCode(args[0], args[1]); } else { DisplayInfo(); return(-1); } } else if (optNameLower == "t2cppm") { var args = opt.Arguments; if (args.Length == 3) { RelationSchemaToCppDatabaseMemoryCode(args[0], args[1], args[2]); } else { DisplayInfo(); return(-1); } } else if (optNameLower == "t2xhtml") { var args = opt.Arguments; if (args.Length == 3) { RelationSchemaToXhtml(args[0], args[1], args[2]); } else { DisplayInfo(); return(-1); } } else { throw new ArgumentException(opt.Name); } } return(0); }