当前位置: 首页>>代码示例>>C#>>正文


C# InflaterInputStream.CopyTo方法代码示例

本文整理汇总了C#中ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream.CopyTo方法的典型用法代码示例。如果您正苦于以下问题:C# InflaterInputStream.CopyTo方法的具体用法?C# InflaterInputStream.CopyTo怎么用?C# InflaterInputStream.CopyTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream的用法示例。


在下文中一共展示了InflaterInputStream.CopyTo方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Inflate

 internal static byte[] Inflate(byte[] buffer)
 {
     InflaterInputStream inflaterStream = new InflaterInputStream(new MemoryStream(buffer));
     MemoryStream outputStream = new MemoryStream();
     inflaterStream.CopyTo(outputStream);
     return outputStream.ToArray();
 }
开发者ID:kkkkyue,项目名称:FtexTool,代码行数:7,代码来源:ZipUtility.cs

示例2: DecompressZlib

 public static byte[] DecompressZlib(byte[] input)
 {
     MemoryStream source = new MemoryStream(input);
     byte[] result = null;
     using (MemoryStream outStream = new MemoryStream())
     {
         using (InflaterInputStream inf = new InflaterInputStream(source))
         {
             inf.CopyTo(outStream);
         }
         result = outStream.ToArray();
     }
     return result;
 }
开发者ID:zeroKilo,项目名称:Zlibber,代码行数:14,代码来源:Form1.cs

示例3: Verify

        public static bool Verify(string licenseString)
        {
            if (string.IsNullOrEmpty(licenseString) || !CanDecode(licenseString))
                return false;

            byte[] licenseData = Convert.FromBase64String(GetLicenceContent(licenseString));
            Console.WriteLine(Encoding.GetEncoding("UTF-32BE").GetString(licenseData.Take(4).ToArray()));
            var length = (((licenseData[0] & 0xff) << 24) | ((licenseData[1] & 0xff) << 16) | ((licenseData[2] & 0xff) << 8) | (licenseData[3] & 0xff));
            var license = licenseData.Skip(4).Take(length).ToArray();
            var sign = licenseData.Skip(length + 4).ToArray();
            byte[] unzipedData;
            using (MemoryStream inStream = new MemoryStream(license.Skip(5).ToArray()))
            using (InflaterInputStream zip = new InflaterInputStream(inStream))
            using (MemoryStream outStream = new MemoryStream())
            {
                zip.CopyTo(outStream);
                unzipedData = outStream.ToArray();
            }
            Console.WriteLine(Encoding.ASCII.GetString(unzipedData));
            return VerifyDsaMessage(Convert.FromBase64String(PublicKey), license, ConvertToP1363Signature(sign));
        }
开发者ID:myso42,项目名称:AtlassianLicense,代码行数:21,代码来源:Version2LicenseDecoder.cs

示例4: PacketReceiverModernAsync

        private void PacketReceiverModernAsync(IAsyncResult ar)
        {
            if (_baseSock == null || _stream == null || !Connected || Crashed)
                return; // -- Terminate cycle

            if (_baseSock.Available > 0)
            {
                int packetId = 0;
                byte[] data = new byte[0];

                #region No Compression

                if (!CompressionEnabled)
                {
                    var packetLength = _stream.ReadVarInt();
                    if (packetLength == 0)
                        throw new Exception("Reading Error: Packet Length size is 0");

                    packetId = _stream.ReadVarInt();

                    data = _stream.ReadByteArray(packetLength - 1);
                }

                #endregion

                #region Compression

                else // (CompressionEnabled)
                {
                    var packetLength = _stream.ReadVarInt();
                    if (packetLength == 0)
                        throw new Exception("Reading Error: Packet Length size is 0");

                    var dataLength = _stream.ReadVarInt();
                    if (dataLength == 0)
                    {
                        if (packetLength >= CompressionThreshold)
                            throw new Exception("Reading Error: Received uncompressed message of size " + packetLength +
                                                " greater than threshold " + CompressionThreshold);

                        packetId = _stream.ReadVarInt();

                        data = _stream.ReadByteArray(packetLength - 2);
                    }
                    else // (dataLength > 0)
                    {
                        var dataLengthBytes = MinecraftStream.GetVarIntBytes(dataLength).Length;

                        var tempBuff = _stream.ReadByteArray(packetLength - dataLengthBytes); // -- Compressed

                        using (var outputStream = new MemoryStream())
                        using (var inputStream = new InflaterInputStream(new MemoryStream(tempBuff)))
                            //using (var reader = new MinecraftDataReader(new MemoryStream(tempBuff), NetworkMode))
                        {
                            inputStream.CopyTo(outputStream);
                            tempBuff = outputStream.ToArray(); // -- Decompressed

                            packetId = tempBuff[0]; // -- Only 255 packets available. ReadVarInt doesn't work.
                            var packetIdBytes = MinecraftStream.GetVarIntBytes(packetId).Length;

                            data = new byte[tempBuff.Length - packetIdBytes];
                            Buffer.BlockCopy(tempBuff, packetIdBytes, data, 0, data.Length);
                        }
                    }
                }

                #endregion

                OnDataReceived(packetId, data);
            }

            // -- If it will throw an error, then the cause is too slow _stream dispose
            _stream.EndRead(ar);
            _stream.BeginRead(new byte[0], 0, 0, PacketReceiverModernAsync, null);
        }
开发者ID:beppe9000,项目名称:MineLib.Network,代码行数:75,代码来源:NetworkHandler.Modern.cs


注:本文中的ICSharpCode.SharpZipLib.Zip.Compression.Streams.InflaterInputStream.CopyTo方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。