コード例 #1
0
ファイル: AppletManifest.cs プロジェクト: vindamle/openiz
        /// <summary>
        /// Create an unsigned package
        /// </summary>
        /// <returns>The package.</returns>
        public AppletPackage CreatePackage(String compression = null)
        {
            AppletPackage retVal = new AppletPackage()
            {
                Meta        = this.Info,
                Compression = compression
            };

            using (MemoryStream ms = new MemoryStream())
            {
                Stream compressStream = null;
                try {
                    switch (compression)
                    {
                    case "lzma":
                        compressStream = new LZipStream(ms, SharpCompress.Compressors.CompressionMode.Compress, leaveOpen: true);
                        break;

                    case "bzip2":
                        compressStream = new BZip2Stream(ms, SharpCompress.Compressors.CompressionMode.Compress, leaveOpen: true);
                        break;

                    case "gzip":
                        compressStream = new GZipStream(ms, SharpCompress.Compressors.CompressionMode.Compress, leaveOpen: true);
                        break;

                    case "none":
                        compressStream = ms;
                        break;

                    default:
                        compressStream = new DeflateStream(ms, SharpCompress.Compressors.CompressionMode.Compress, leaveOpen: true);
                        break;
                    }
                    XmlSerializer xsz = new XmlSerializer(typeof(AppletManifest));
                    xsz.Serialize(compressStream, this);
                }
                finally
                {
                    compressStream.Dispose();
                }
                retVal.Manifest = ms.ToArray();
            }
            return(retVal);
        }
コード例 #2
0
ファイル: AppletPackage.cs プロジェクト: lulzzz/openiz
 /// <summary>
 /// Load the specified manifest name
 /// </summary>
 public static AppletPackage Load(byte[] resourceData)
 {
     using (MemoryStream ms = new MemoryStream(resourceData))
         return(AppletPackage.Load(ms));
 }