Ejemplo n.º 1
0
        static void convertJmp(jmp jmp, string path, IoFormat format)
        {
            using (var file = File.Create(path)) {
                switch (format)
                {
                case IoFormat.JMP: {
                    var writer = new aBinaryWriter(file, Endianness.Big, Encoding.GetEncoding(932));
                    jmp.save(writer);
                    break;
                }

                case IoFormat.XML: {
                    var settings = new XmlWriterSettings()
                    {
                        OmitXmlDeclaration = true,
                        Encoding           = Encoding.UTF8,
                        NewLineChars       = "\n",
                        IndentChars        = "\t",
                        Indent             = true,
                    };
                    var writer = XmlWriter.Create(file, settings);
                    jmp.save(writer);
                    writer.Close();
                    break;
                }
                }
            }
        }
Ejemplo n.º 2
0
        static jmp loadJmp(string path, IoFormat format)
        {
            var jmp = new jmp();

            jmp.SetNameResolver(lookupName);
            using (var file = File.OpenRead(path)) {
                switch (format)
                {
                case IoFormat.JMP: {
                    var reader = new aBinaryReader(file, Endianness.Big, Encoding.GetEncoding(932));
                    jmp.load(reader);
                    break;
                }

                case IoFormat.XML: {
                    var document = new xDocument(file);
                    jmp.load(document.Root);
                    break;
                }
                }
            }
            return(jmp);
        }