System.IO.Compression.ZLibNative.CreateZLibStreamForInflate C# (CSharp) Méthode

CreateZLibStreamForInflate() private méthode

private CreateZLibStreamForInflate ( ZLibStreamHandle &zLibStreamHandle, int windowBits ) : ErrorCode
zLibStreamHandle ZLibStreamHandle
windowBits int
Résultat ErrorCode
        public static ErrorCode CreateZLibStreamForInflate(out ZLibStreamHandle zLibStreamHandle, int windowBits)
        {
            zLibStreamHandle = new ZLibStreamHandle();
            return zLibStreamHandle.InflateInit2_(windowBits);
        }

Usage Example

Exemple #1
0
        private void InflateInit(int windowBits)
        {
            ZLibNative.ErrorCode error;
            try
            {
                error = ZLibNative.CreateZLibStreamForInflate(out _zlibStream, windowBits);
            }
            catch (Exception exception) // could not load the ZLib dll
            {
                throw new ZLibException("SR.ZLibErrorDLLLoadError", exception);
            }

            switch (error)
            {
            case ZLibNative.ErrorCode.Ok:               // Successful initialization
                return;

            case ZLibNative.ErrorCode.MemError:         // Not enough memory
                throw new ZLibException("SR.ZLibErrorNotEnoughMemory", "inflateInit2_", (int)error, _zlibStream.GetErrorMessage());

            case ZLibNative.ErrorCode.VersionError:     //zlib library is incompatible with the version assumed
                throw new ZLibException("SR.ZLibErrorVersionMismatch", "inflateInit2_", (int)error, _zlibStream.GetErrorMessage());

            case ZLibNative.ErrorCode.StreamError:      // Parameters are invalid
                throw new ZLibException("SR.ZLibErrorIncorrectInitParameters", "inflateInit2_", (int)error, _zlibStream.GetErrorMessage());

            default:
                throw new ZLibException("SR.ZLibErrorUnexpected", "inflateInit2_", (int)error, _zlibStream.GetErrorMessage());
            }
        }