Exemple #1
0
        public static bool TryLoading(out ICompressorFactory?compressorFactory, out IDecompressorFactory?decompressorFactory)
        {
            try
            {
                var assembly = Assembly.Load("IronSnappy");

                var definedTypes = assembly.DefinedTypes.ToArray();

                var snappy = FindSnappy(definedTypes);

                var methods = snappy.GetMethods(BindingFlags.Public | BindingFlags.Static);

                var decode = FindDecode(methods);
                var encode = FindEncode(methods);

                compressorFactory   = new CompressorFactory(PulsarApi.CompressionType.Snappy, () => new Compressor(CreateCompressor(encode)));
                decompressorFactory = new DecompressorFactory(PulsarApi.CompressionType.Snappy, () => new Decompressor(CreateDecompressor(decode)));
                return(true);
            }
            catch
            {
                // Ignore
            }

            compressorFactory   = null;
            decompressorFactory = null;

            return(false);
        }
Exemple #2
0
        public static bool TryLoading(out ICompressorFactory?compressorFactory, out IDecompressorFactory?decompressorFactory)
        {
            try
            {
                var assembly = Assembly.Load("DotNetZip");

                var definedTypes = assembly.DefinedTypes.ToArray();

                var ZlibStream = FindZlibStream(definedTypes);

                var methods = ZlibStream.GetMethods(BindingFlags.Public | BindingFlags.Static);

                var compressBuffer   = FindCompressBuffer(methods);
                var uncompressBuffer = FindUncompressBuffer(methods);

                compressorFactory   = new CompressorFactory(PulsarApi.CompressionType.Zlib, () => new Compressor(CreateCompressor(compressBuffer)));
                decompressorFactory = new DecompressorFactory(PulsarApi.CompressionType.Zlib, () => new Decompressor(CreateDecompressor(uncompressBuffer)));
                return(true);
            }
            catch
            {
                // Ignore
            }

            compressorFactory   = null;
            decompressorFactory = null;

            return(false);
        }
        public static bool TryLoading(out ICompressorFactory?compressorFactory, out IDecompressorFactory?decompressorFactory)
        {
            try
            {
                var assembly = Assembly.Load("K4os.Compression.LZ4");

                var definedTypes = assembly.DefinedTypes.ToArray();

                var lz4Codec = FindLZ4Codec(definedTypes);
                var lz4Level = FindLZ4Level(definedTypes);

                var methods = lz4Codec.GetMethods(BindingFlags.Public | BindingFlags.Static);

                var decode            = FindDecode(methods);
                var encode            = FindEncode(methods, lz4Level);
                var maximumOutputSize = FindMaximumOutputSize(methods);

                compressorFactory   = new CompressorFactory(PulsarApi.CompressionType.Lz4, () => new Compressor(CreateCompressor(encode, maximumOutputSize)));
                decompressorFactory = new DecompressorFactory(PulsarApi.CompressionType.Lz4, () => new Decompressor(CreateDecompressor(decode)));
                return(true);
            }
            catch
            {
                // Ignore
            }

            compressorFactory   = null;
            decompressorFactory = null;

            return(false);
        }