public static XMBFile FromDocument(XDocument xdoc) { var xmb = new XMBFile(); xmb.document = xdoc; return(xmb); }
public static XMBFile Load(Stream cmpStream) { var newStream = DecompressAndSkipHeader(cmpStream); string data = new StreamReader(newStream).ReadToEnd(); var xmb = new XMBFile(); if (data.Trim().StartsWith("<")) { xmb.document = XDocument.Parse(data); } else { newStream.Position = 0; var b0 = newStream.ReadByte(); var b1 = newStream.ReadByte(); XElement root = new XElement("tmp"); var reader = new BinaryReader(newStream); var serializer = new SerialReader(reader); Serialize(root, serializer); /*char[] header = new char[2]; * reader.Read(header, 0, 2); * Debug.Assert(header[0] == 'X' && header[1] == '1'); * byte[] buffer = new byte[1024]; * reader.Read(buffer, 0, 14); * * var elements = ReadStringArray(reader); * var parameters = ReadStringArray(reader); * * XElement root = ReadElement(reader, elements, parameters);*/ xmb.document = new XDocument(root); } return(xmb); }