public static void TreeToBinary(String TreePath, String BinaryPath, 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(); var Data = TreeFile.ReadFile(TreePath); var b = tbc.TreeToBinary(t, Data); var Dir = FileNameHandling.GetFileDirectory(BinaryPath); if (Dir != "" && !Directory.Exists(Dir)) { Directory.CreateDirectory(Dir); } using (var s = Streams.CreateWritable(BinaryPath)) { s.Write(b); } }
public static Configuration LoadConfiguration() { var x = TreeFile.ReadFile("Configuration.tree"); var c = (new XmlSerializer()).Read <Configuration>(x); return(c); }
private void Window_Loaded(object sender, RoutedEventArgs e) { ConfigurationFilePath = Path.Combine(Environment.CurrentDirectory, Assembly.GetEntryAssembly().GetName().Name + ".exe.ini"); if (!File.Exists(ConfigurationFilePath)) { ConfigurationFilePath = Assembly.GetEntryAssembly().Location + ".ini"; } if (File.Exists(ConfigurationFilePath)) { var x = TreeFile.ReadFile(ConfigurationFilePath); c = (new XmlSerializer()).Read <Configuration>(x); } else { c = new Configuration(); c.IP = "127.0.0.1"; c.Port = 8001; c.Mode = Mode.Binary; c.SchemaPaths = new List <String> { "../Examples/Communication/Schema/Common", "../Examples/Communication/Schema/Communication", "../Examples/Communication/Schema/Compatibility" }; } TextBox_IP.Text = c.IP; TextBox_Port.Text = c.Port.ToInvariantString(); ComboBox_Mode.SelectedIndex = (int)c.Mode; }
public static void TreeToJson(String TreePath, String JsonPath) { var xs = new XmlSerializer(true); var x = TreeFile.ReadFile(TreePath); var o = xs.Read <World.World>(x); var j = World.Json.JsonTranslator.WorldToJson(o); var t = j.ToString(Niveum.Json.Formatting.Indented); Txt.WriteFile(JsonPath, t); }
public static void TreeToBinaryWithFirefly(String TreePath, String BinaryPath) { var tbc = new TreeBinaryConverter(); var Data = TreeFile.ReadFile(TreePath); var b = tbc.TreeToBinary <World.World>(Data); using (var s = Streams.CreateWritable(BinaryPath)) { s.Write(b); } }
public static ObjectSchemaTemplateInfo FromBinary(Byte[] Bytes) { XElement x; using (ByteArrayStream s = new ByteArrayStream(Bytes)) { using (var sr = Txt.CreateTextReader(s.AsNewReading(), TextEncoding.Default, true)) { x = TreeFile.ReadFile(sr); } } XmlSerializer xs = new XmlSerializer(); var t = xs.Read <ObjectSchemaTemplate>(x); var ti = new ObjectSchemaTemplateInfo(t); return(ti); }
public static void TreeToBinary(String TreePath, String BinaryPath) { var xs = new XmlSerializer(true); var x = TreeFile.ReadFile(TreePath); var o = xs.Read <World.World>(x); Byte[] b; using (var s = new World.BinaryWithoutFirefly.ByteArrayStream()) { World.BinaryWithoutFirefly.BinaryTranslator.WorldToBinary(s, o); s.Position = 0; b = s.ReadBytes(s.Length); } using (var s = Streams.CreateWritable(BinaryPath)) { s.Write(b); } }