コード例 #1
0
 public virtual void Dispose()
 {
     if (m_disposeCompression && m_compression != null)
     {
         m_compression.Dispose();
         m_compression = null;
     }
 }
コード例 #2
0
        public bool TryGetCompressionFromRequest(HttpRequestBase request, out ICompression compression)
        {
            var acceptEncodingHeader = request.Headers["Accept-Encoding"];
            if (string.IsNullOrEmpty(acceptEncodingHeader))
            {
                compression = null;
                return false;
            }

            compression = m_compressions.FirstOrDefault(c => acceptEncodingHeader.IndexOf(c.ContentEncoding, StringComparison.InvariantCultureIgnoreCase) > -1);
            return compression != null;
        }
コード例 #3
0
        public virtual void Dispose()
        {
            if (m_compression != null)
                try { m_compression.Dispose(); }
                finally { m_compression = null; }

            if (m_localfile != null)
                try { m_localfile.Dispose(); }
                finally { m_localfile = null; }

            m_volumename = null;
        }
コード例 #4
0
        public VolumeWriterBase(Options options, DateTime timestamp)
            : base(options)
        {
            m_localfile = new Library.Utility.TempFile();

			m_volumename = GenerateFilename(this.FileType, options.Prefix, GenerateGuid(options), timestamp, options.CompressionModule, options.NoEncryption ? null : options.EncryptionModule);
            m_compression = DynamicLoader.CompressionLoader.GetModule(options.CompressionModule, m_localfile, options.RawOptions);
            
            if(m_compression == null)
                throw new Exception(string.Format("Unsupported compression module: {0}", options.CompressionModule));
            
            if ((this is IndexVolumeWriter || this is FilesetVolumeWriter) && m_compression is Library.Interface.ICompressionHinting)
                ((Library.Interface.ICompressionHinting)m_compression).LowOverheadMode = true;
                
            AddManifestfile();
        }
コード例 #5
0
        public static IEnumerable<string> ReadBlocklist(ICompression compression, string filename, long hashsize)
        {
            var buffer = new byte[hashsize];
            using(var fs = compression.OpenRead(filename))
            {
                int s;
                while ((s = Library.Utility.Utility.ForceStreamRead(fs, buffer, buffer.Length)) != 0)
                {                    
                    if (s != buffer.Length)
                        throw new InvalidDataException("Premature End-of-stream encountered while reading blocklist hashes");

                    yield return Convert.ToBase64String(buffer);
                }

            }
        }
コード例 #6
0
     public VolumeReaderBase(ICompression compression, Options options)
         : base(options)
     {
         m_compression = compression;
         if (!options.DontReadManifests)
         {
             using (var s = m_compression.OpenRead(MANIFEST_FILENAME))
             {
                 if (s == null)
                     throw new InvalidManifestException("No manifest file found in volume");
 
                 using (var fs = new StreamReader(s, ENCODING))
                     ManifestData.VerifyManifest(fs.ReadToEnd(), m_blocksize, options.BlockHashAlgorithm, options.FileHashAlgorithm);
             }
         }
     }
コード例 #7
0
        public DataCompressor(ICompression compression)
        {
            Ensure.ArgumentNotNull(compression, "compression");

            _compression = compression;
        }
コード例 #8
0
 public DocumentOverload(IAes aes, ISecureHash secureHash, ICompression compression, IPassword password, IFileProxy fileProxy)
     : base(aes, secureHash, compression, password, fileProxy)
 {
 }
コード例 #9
0
 public void SetStrategy(ICompression compression)
 {
     this.Compression = compression;
 }
コード例 #10
0
 public BasicClient(ITableGenerator tableGenerator, IBasicService basicService, ISerialisation serialisation, ICompression compression, IEncryption encryption, TokenTableSet tokenTableSet)
 {
     _tableGenerator = tableGenerator;
     _basicService   = basicService;
     _serialisation  = serialisation;
     _compression    = compression;
     _encryption     = encryption;
     if (tokenTableSet == null)
     {
         _tokenTableSet = GenerateTokenTable();
     }
     else
     {
         _tokenTableSet = tokenTableSet;
     }
 }
コード例 #11
0
 public ControlFileEnumerable(ICompression compression)
 {
     m_compression = compression;
 }
コード例 #12
0
 public InMemorySerializer(ICompression encoder)
 {
     this.Encoder = encoder;
 }
コード例 #13
0
 public ChunkReadStream(Stream baseStream, ICompression compression)
 {
     _baseStream  = baseStream;
     _compression = compression;
 }
コード例 #14
0
ファイル: Connection.cs プロジェクト: pietpukkel/xmpp
 private void StartCompression(string algorithm)
 {
     _compression = Static.CompressionRegistry.GetCompression(algorithm);
     _isCompressionEnabled = true;
 }
コード例 #15
0
 /**
  * Set the delegate implementation.
  *
  * @param _delegate The delegate implementing platform specific functions.
  */
 public void SetDelegate(ICompression _delegate)
 {
     this._delegate = _delegate;
 }
コード例 #16
0
 public State(IReadable readable, ICompression compressor)
 {
     _readable  = readable;
     Compressor = compressor;
     Temp       = new TempStream();
 }
コード例 #17
0
 /**
  * Constructor with delegate.
  *
  * @param _delegate The delegate implementing platform specific functions.
  */
 public CompressionBridge(ICompression _delegate) : base()
 {
     this._delegate = _delegate;
 }
コード例 #18
0
ファイル: AsyncSocket.cs プロジェクト: shubhanshusingh/xmpp
 /// <summary>
 /// </summary>
 /// <param name="algorithm"></param>
 public void StartCompression(string algorithm)
 {
     _compression = CompressionRegistry.GetCompression(algorithm);
     _compressed = true;
 }
コード例 #19
0
 private static void TestStubsForDocument(out IAes aes, out ISecureHash hash, out IPassword password, out IFileProxy fileProxy, out ICompression compression)
 {
     aes         = new TestAES();
     hash        = new TestSecureHash();
     password    = new Password("password", "password");
     fileProxy   = new TestFileProxy();
     compression = new TestCompression();
 }
コード例 #20
0
 public FileEntryEnumerable(ICompression compression)
 {
     m_compression = compression;
 }
コード例 #21
0
 public PhotoProcessor(IFilter filter, ICompression compression)
 {
     this._compression = compression;
     this._filter      = filter;
 }
コード例 #22
0
 public ControlFileEnumerator(ICompression compression)
 {
     m_compression = compression;
     this.Reset();
 }
コード例 #23
0
        public DataCompressor(ICompression compression)
        {
            Ensure.ArgumentNotNull(compression, "compression");

            _compression = compression;
        }
コード例 #24
0
 public FilesetVolumeReader(ICompression compression, Options options)
     : base(compression, options)
 {
 }
コード例 #25
0
ファイル: IndexVolumeReader.cs プロジェクト: vnau/duplicati
 public IndexVolumeReader(ICompression compression, Options options, long hashsize)
     : base(compression, options)
 {
     m_hashsize = hashsize;
 }
コード例 #26
0
 public OSPSuiteExecutionContext(IOSPSuiteXmlSerializerRepository modelingXmlSerializerRepository, ICompression compress, IEventPublisher eventPublisher)
 {
     _modelingXmlSerializerRepository = modelingXmlSerializerRepository;
     _compress       = compress;
     _eventPublisher = eventPublisher;
     Project         = new TestProject();
 }
コード例 #27
0
ファイル: Connection.cs プロジェクト: jaworskig/xmpp
 private void StartCompression(string algorithm)
 {
     _compression          = Static.CompressionRegistry.GetCompression(algorithm);
     _isCompressionEnabled = true;
 }
コード例 #28
0
 public CompressionContext(ICompression compression)
 {
     this.Compression = Compression;
 }
コード例 #29
0
 /// <summary>
 /// Create a new POST request.
 /// </summary>
 /// <param name="route">The route.</param>
 /// <param name="content">The content of the request.</param>
 /// <param name="formatter">The formatter use to serialize the content.</param>
 /// <param name="compression">Add compresion system use to compress content.</param>
 /// <returns>The new request.</returns>
 public IParameterRequest PostRequest <TContent>(string route, TContent content, IFormatter formatter = null, ICompression compression = null)
 {
     return(new Request(HttpMethod.Post, route, this).
            AddContent <TContent>(content, formatter, compression));
 }
コード例 #30
0
ファイル: AsyncSocket.cs プロジェクト: yangnanhaohnhn/xmpp
 /// <summary>
 /// </summary>
 /// <param name="algorithm"></param>
 public void StartCompression(string algorithm)
 {
     _compression = CompressionRegistry.GetCompression(algorithm);
     _compressed  = true;
 }
コード例 #31
0
 public BasicClientFactory(ISerialisation serialisation, ICompression compression, IEncryption encryption)
 {
     _serialisation = serialisation;
     _compression   = compression;
     _encryption    = encryption;
 }
コード例 #32
0
 public virtual void Close()
 {
     if (m_compression != null)
         try { m_compression.Dispose(); }
         finally { m_compression = null; }
 }
コード例 #33
0
 public MessageEncoding(ICompression compression)
 {
     this._compression = compression;
 }
コード例 #34
0
 protected override void ProcessCompression(ICompression compression, Stream input, Stream output)
 {
     compression.Compress(input, output);
 }
コード例 #35
0
 /// <summary>
 /// Create a new PATCH request.
 /// </summary>
 /// <param name="route">The route.</param>
 /// <param name="content">The content of the request</param>
 /// <param name="serializer">The serializer use to serialize it</param>
 /// <param name="compression">Add compresion system use ton compress content</param>
 /// <returns>The new request.</returns>
 public IParameterRequest PatchRequest <TContent>(string route, TContent content, IFormatter serializer = null, ICompression compression = null)
 {
     return(new Request(_PatchMethod, route, this).
            AddContent <TContent>(content, serializer, compression));
 }
コード例 #36
0
 /// <summary>
 /// Create a new PUT request.
 /// </summary>
 /// <param name="content">The content of the request.</param>
 /// <param name="formatter">The formatter use to serialize the content.</param>
 /// <param name="compression">Add compresion system use to compress content.</param>
 /// <returns>The new request.</returns>
 public IParameterRequest PutRequest <TContent>(TContent content, IFormatter formatter = null, ICompression compression = null)
 {
     return(new Request(HttpMethod.Put, null, this).
            AddContent <TContent>(content, formatter, compression));
 }
コード例 #37
0
 public BlockVolumeReader(ICompression compression, Options options)
     : base(compression, options)
 {
 }
コード例 #38
0
 public VolumeReaderBase(ICompression compression, Options options)
     : base(options)
 {
     m_compression = compression;
     ReadManifests(options);
 }
コード例 #39
0
        public string ReadText(Structure structure)
        {
            if (this._disposed)
            {
                throw new ObjectDisposedException("stream");
            }
            if (structure is null)
            {
                throw new ArgumentNullException(nameof(structure));
            }

            var          decompressedByteList = new List <byte>();
            ICompression compression          = null;
            Encoding     encoding             = Encoding.UTF8;
            ushort       maxRecordSize        = 4096;

            if (structure.PalmDOCHeader != null)
            {
                if (structure.PalmDOCHeader.RecordSize > 0)
                {
                    maxRecordSize = structure.PalmDOCHeader.RecordSize;
                }
                switch (structure.PalmDOCHeader.Compression)
                {
                case CompressionType.PalmDOC:
                {
                    compression = new PalmDocCompression();
                }
                break;

                case CompressionType.HUFF_CDIC:
                {
                    compression = CreateHuffCdicCompression(structure.MobiHeader);
                }
                break;

                default:
                {
                    compression = new NoneCompression();
                }
                break;
                }
            }

            if (structure.MobiHeader != null)
            {
                var firstTextRecordIndex    = this.FindFirstTextRecordIndex(structure.MobiHeader);
                var firstNonTextRecordIndex = this.FindFirstNonTextRecordIndex(structure.MobiHeader);
                for (int i = firstTextRecordIndex; i < firstNonTextRecordIndex; i++)
                {
                    var recordBytes            = this.ReadPalmDBRecord(this._palmDBRecordList[i]);
                    var decompressedBytes      = compression.Decompress(recordBytes);
                    var fixedDecompressedBytes = decompressedBytes.Length > maxRecordSize?
                                                 decompressedBytes.Take(maxRecordSize) :
                                                     decompressedBytes;

                    decompressedByteList.AddRange(fixedDecompressedBytes);
                }
            }

            return(encoding.GetString(decompressedByteList.ToArray()));
        }
コード例 #40
0
 public BlockVolumeReader(ICompression compression, Options options)
     : base(compression, options)
 {
 }
コード例 #41
0
ファイル: ChunkWriteStream.cs プロジェクト: oleg-st/DevSync
 public ChunkWriteStream(Stream stream, ICompression compression)
 {
     _flusher = new ChunkWriteStreamFlusher(stream, compression);
     _flusher.Start();
 }