public static IPackage LoadPackage(string filename) { var fs = File.OpenRead(filename); var s = new BinaryFileHelper(fs); try { if (s.ReadString() != "HuiDesktopPackage") { throw new InvalidDataException(); } var version = s.ReadByte(); switch (version) { case 3: return(new V3Package(fs)); case 4: return(new V4Package(fs)); default: throw new NotSupportedException(); } } catch (EndOfStreamException) { throw new InvalidDataException(); } }
public V4Package(Stream stream) { var reader = new BinaryFileHelper(new System.IO.Compression.DeflateStream(stream, System.IO.Compression.CompressionMode.Decompress)); //var reader = new BinaryFileHelper(stream); strongName = reader.ReadString(); friendlyName = reader.ReadString(); description = reader.ReadString(); for (int i = reader.ReadUnsignedInt(); i > 0; --i) { var name = reader.ReadString(); var url = reader.ReadString(); var d = new List <string>(); for (int ii = reader.ReadUnsignedInt(); ii > 0; --ii) { d.Add(reader.ReadString()); } startupInfos.Add(new StartupInfo { dependencies = d, name = name, url = url, fromPackage = this }); } for (int i = reader.ReadUnsignedInt(); i > 0; --i) { string name = reader.ReadString(); int length = reader.ReadUnsignedInt(); var mem = new MemoryStream(); reader.CopyTo(mem, length); files[name] = mem; } }