コード例 #1
0
        public static TObject Deserialize <TObject>(Stream inStream) where TObject : class
        {
            using (MemoryStream ms = new MemoryStream())
            {
                XmlSerializer xs     = new XmlSerializer(typeof(TObject));
                var           xmlDoc = CryXmlSerializer.ReadStream(inStream);

                xmlDoc.Save(ms);
                ms.Seek(0, SeekOrigin.Begin);
                return(xs.Deserialize(ms) as TObject);
            }
        }
コード例 #2
0
        public static TObject Deserialize <TObject>(String inFile, ByteOrderEnum byteOrder = ByteOrderEnum.BigEndian, Boolean writeLog = false) where TObject : class
        {
            using (MemoryStream ms = new MemoryStream())
            {
                var xmlDoc = CryXmlSerializer.ReadFile(inFile, byteOrder, writeLog);

                xmlDoc.Save(ms);

                ms.Seek(0, SeekOrigin.Begin);

                XmlSerializer xs = new XmlSerializer(typeof(TObject));

                return(xs.Deserialize(ms) as TObject);
            }
        }
コード例 #3
0
 public static XmlDocument ReadFile(String inFile, ByteOrderEnum byteOrder = ByteOrderEnum.AutoDetect, Boolean writeLog = false)
 {
     return(CryXmlSerializer.ReadStream(File.OpenRead(inFile), byteOrder, writeLog));
 }
コード例 #4
0
        public static void Process(params String[] args)
        {
            if (args.Length < 1 || args.Length > 2)
            {
                Console.WriteLine("Usage: HoloXPLOR.DataForge.exe [infile]");
                Console.WriteLine();
                Console.WriteLine("Converts any Star Citizen binary file into an actual XML file.");
                Console.WriteLine("CryXml files (.xml) are saved as .raw in the original location.");
                Console.WriteLine("DataForge files (.dcb) are saved as .xml in the original location.");
                Console.WriteLine();
                Console.WriteLine("Can also convert all compatible files in a directory, and it's");
                Console.WriteLine("sub-directories. In that case, all CryXml files are saved in-place,");
                Console.WriteLine("and any DataForge files are saved to both .xml and extracted to");
                Console.WriteLine("the original component locations.");
                return;
            }

            try
            {
                if (File.Exists(args[0]))
                {
                    if (Path.GetExtension(args[0]) == ".dcb")
                    {
                        using (BinaryReader br = new BinaryReader(File.OpenRead(args[0])))
                        {
                            var legacy = new FileInfo(args[0]).Length < 0x0e2e00;

                            var df = new DataForge(br, legacy);

                            df.GenerateSerializationClasses();

                            df.Save(Path.ChangeExtension(args[0], "xml"));
                        }
                    }
                    else
                    {
                        var xml = CryXmlSerializer.ReadFile(args[0]);

                        if (xml != null)
                        {
                            if (_overwrite)
                            {
                                xml.Save(args[0]);
                            }
                            else
                            {
                                xml.Save(Path.ChangeExtension(args[0], "raw"));
                            }
                        }
                        else
                        {
                            Console.WriteLine("{0} already in XML format", args[0]);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error converting {0}: {1}", args[0], ex.Message);
            }
        }
コード例 #5
0
 public static XmlDocument ReadFile(String inFile, Boolean writeLog = false)
 {
     return(CryXmlSerializer.ReadStream(File.OpenRead(inFile), writeLog));
 }