예제 #1
0
파일: AionData.cs 프로젝트: webdes27/aiondb
        public static XDocument BXMLToXML(BinaryXmlFile bxml)
        {
            XDocument doc = new XDocument();

            doc.Add(FromBXMLNode(doc, bxml.Root));
            return(doc);
        }
예제 #2
0
        public static void Main(string[] args)
        {
            bool showHelp = false;

            var options = new OptionSet()
            {
                { "h|help", "show this message and exit", v => showHelp = v != null },
            };

            List <string> extras;

            try
            {
                extras = options.Parse(args);
            }
            catch (OptionException e)
            {
                Console.Write("{0}: ", GetExecutableName());
                Console.WriteLine(e.Message);
                Console.WriteLine("Try `{0} --help' for more information.", GetExecutableName());
                return;
            }

            if (extras.Count < 1 || extras.Count > 2 || showHelp == true)
            {
                Console.WriteLine("Usage: {0} [OPTIONS]+ input_binary [output_xml]", GetExecutableName());
                Console.WriteLine();
                Console.WriteLine("Options:");
                options.WriteOptionDescriptions(Console.Out);
                return;
            }

            var inputPath  = Path.GetFullPath(extras[0]);
            var outputPath = extras.Count > 1 ? extras[1] : Path.ChangeExtension(inputPath, null) + "_converted.xml";

            BinaryXmlFile binaryXml;

            using (var input = File.OpenRead(inputPath))
            {
                binaryXml = new BinaryXmlFile();
                binaryXml.Read(input);
            }

            using (var output = File.Create(outputPath))
                using (var writer = new XmlTextWriter(output, Encoding.UTF8))
                {
                    writer.Formatting = Formatting.Indented;
                    writer.WriteStartDocument();
                    WriteNode(writer, binaryXml.Root);
                    writer.WriteEndDocument();
                    writer.Flush();
                }
        }
예제 #3
0
파일: AionData.cs 프로젝트: webdes27/aiondb
        public BinaryXmlFile ReadXMLFile(string pakFile, string internalFile)
        {
            var itempak = OpenPAKFile(Path.Combine(aionPath, pakFile));

            Debug.Assert(internalFile.EndsWith("xml"));
            using (ZipFile zFile = new ZipFile(itempak)) {
                var           assemblyItems = zFile[internalFile];
                BinaryXmlFile bxml          = new BinaryXmlFile();
                bxml.Read(zFile.GetInputStream(assemblyItems));
                return(bxml);
            }
        }
예제 #4
0
        public XMLViewer(string file, byte[] xml)
        {
            InitializeComponent();

            try {
                BinaryXmlFile f = new BinaryXmlFile();
                f.Read(new MemoryStream(xml));
                treeView1.Nodes.Add(MakeTree(f.Root));
                Text = "bxml://" + file;
            } catch {
                XmlDocument xdoc = new XmlDocument();
                xdoc.Load(new MemoryStream(xml));
                treeView1.Nodes.Add(MakeTree(xdoc));
                Text = "xml://" + file;
            }
        }
예제 #5
0
        public XMLViewer(string file, byte[] xml)
        {
            InitializeComponent();

            try {
                BinaryXmlFile f = new BinaryXmlFile();
                f.Read(new MemoryStream(xml));
                treeView1.Nodes.Add(MakeTree(f.Root));
                Text = "bxml://" + file;

            } catch {
                XmlDocument xdoc = new XmlDocument();
                xdoc.Load(new MemoryStream(xml));
                treeView1.Nodes.Add(MakeTree(xdoc));
                Text = "xml://" + file;
            }
        }
예제 #6
0
        private static void InsertBXMLData <T>(SQLiteConnection conn, string table, BinaryXmlFile bxml, Func <FieldInfo, string, string> stringModifier) where T : new()
        {
            int count = 0;

            foreach (var node in bxml.Root.Children)
            {
                object item = new T();
                foreach (var attr in node.Children)
                {
                    var fi = typeof(T).GetField(attr.Name);
                    if (fi.FieldType == typeof(int))
                    {
                        fi.SetValue(item, int.Parse(attr.Value));
                    }
                    else if (fi.FieldType == typeof(double))
                    {
                        fi.SetValue(item, double.Parse(attr.Value));
                    }
                    else if (fi.FieldType == typeof(bool))
                    {
                        fi.SetValue(item, bool.Parse(attr.Value));
                    }
                    else if (fi.FieldType.IsEnum)
                    {
                        fi.SetValue(item, Enum.Parse(fi.FieldType, attr.Value.Replace('-', '_'), true));
                    }
                    else
                    {
                        var modified = attr.Value == null ? null : stringModifier(fi, attr.Value);
                        fi.SetValue(item, modified);
                    }
                }
                count++;
                if (count % 100 == 0)
                {
                    Console.WriteLine("Processed {0} items for {1}", count, table);
                }
                conn.Insert(table, (T)item);
            }
        }
예제 #7
0
 public BinaryXmlFile ReadXMLFile(string pakFile, string internalFile)
 {
     var itempak = OpenPAKFile(Path.Combine(aionPath, pakFile));
     Debug.Assert(internalFile.EndsWith("xml"));
     using (ZipFile zFile = new ZipFile(itempak)) {
         var assemblyItems = zFile[internalFile];
         BinaryXmlFile bxml = new BinaryXmlFile();
         bxml.Read(zFile.GetInputStream(assemblyItems));
         return bxml;
     }
 }
예제 #8
0
 public static XDocument BXMLToXML(BinaryXmlFile bxml)
 {
     XDocument doc = new XDocument();
     doc.Add(FromBXMLNode(doc, bxml.Root));
     return doc;
 }