Ejemplo n.º 1
0
        /// <summary>
        /// Compress the data in this object according to the set parameters
        /// </summary>
        /// <returns>A new instance of ED with compressed data</returns>
        /// <example>ED with compressed data
        /// <code lang="cs" title="ED compression">
        /// <![CDATA[
        /// // Create instance
        /// ED test = new ED(File.ReadAllBytes("C:\\output.pdf"), "text/xml");
        /// Console.WriteLine("Original: {0}", test.Data.Length);
        ///
        /// // Setup compression
        /// compressed = test.Compress(EncapsulatedDataCompression.GZ);
        /// Console.WriteLine("Compressed: {0}", compressed.Data.Length);
        /// // Setup integrity check
        /// compressed.IntegrityCheckAlgorithm = EncapsulatedDataIntegrityAlgorithm.SHA256;
        /// compressed.IntegrityCheck = compressed.ComputeIntegrityCheck();
        /// // Validate
        /// if (!compressed.ValidateIntegrityCheck())
        /// Console.WriteLine("Integrity check doesn't match!");
        /// else
        /// {
        /// test = compressed.UnCompress();
        /// Console.WriteLine("UnCompressed: {0}", test.Data.Length);
        /// }
        /// ]]>
        /// </code>
        /// </example>
        /// <exception cref="T:System.InvalidOperationException">When <paramref name="compressionMethod"/> is not supported by this function</exception>
        public ED Compress(EncapsulatedDataCompression compressionMethod)
        {
            ED retVal = this.Clone() as ED;

            retVal.Compression = compressionMethod;
            retVal.Data        = retVal.CompressInternal();

            if (retVal.IntegrityCheckAlgorithm != null)
            {
                retVal.IntegrityCheck = retVal.ComputeIntegrityCheck();
            }

            return(retVal);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Compress the data in this object according to the set parameters
        /// </summary>
        /// <returns>A new instance of ED with compressed data</returns>
        /// <example>ED with compressed data
        /// <code lang="cs" title="ED compression">
        /// <![CDATA[
        /// // Create instance
        /// ED test = new ED(File.ReadAllBytes("C:\\output.pdf"), "text/xml");
        /// Console.WriteLine("Original: {0}", test.Data.Length);
        ///
        /// // Setup compression
        /// compressed = test.Compress(EncapsulatedDataCompression.GZ);
        /// Console.WriteLine("Compressed: {0}", compressed.Data.Length);
        /// // Setup integrity check
        /// compressed.IntegrityCheckAlgorithm = EncapsulatedDataIntegrityAlgorithm.SHA256;
        /// compressed.IntegrityCheck = compressed.ComputeIntegrityCheck();
        /// // Validate
        /// if (!compressed.ValidateIntegrityCheck())
        /// Console.WriteLine("Integrity check doesn't match!");
        /// else
        /// {
        /// test = compressed.UnCompress();
        /// Console.WriteLine("UnCompressed: {0}", test.Data.Length);
        /// }
        /// ]]>
        /// </code>
        /// </example>
        /// <exception cref="T:System.InvalidOperationException">When <paramref name="compressionMethod"/> is not supported by this function</exception>
        public ED Compress(EncapsulatedDataCompression compressionMethod)
        {
            #if WINDOWS_PHONE
            throw new NotSupportedException("Compression is not supported by the Windows Phone Version of Everest");
            #else
            ED retVal = this.Clone() as ED;
            retVal.Compression = compressionMethod;
            retVal.Data        = retVal.CompressInternal();

            if (retVal.IntegrityCheckAlgorithm != null)
            {
                retVal.IntegrityCheck = retVal.ComputeIntegrityCheck();
            }

            return(retVal);
            #endif
        }