Exemplo n.º 1
0
        public static ICompressor New(CompressorType typeId)
        {
            ICompressor compressor = null;

            switch (typeId)
            {
            case CompressorType.None: compressor = new NoneCompressor();        break;

            case CompressorType.Zip: try { compressor = new ZipNativeCompressor(); }
                catch { compressor = new ZipManagedCompressor(); }   break;

            case CompressorType.BZip2: try { compressor = new BZ2NativeCompressor(); }
                catch { compressor = new BZ2ManagedCompressor(); }   break;

            case CompressorType.NativeZip: compressor = new ZipNativeCompressor();   break;

            case CompressorType.ManagedZip: compressor = new ZipManagedCompressor();  break;

            case CompressorType.NativeBZip2: compressor = new BZ2NativeCompressor();   break;

            case CompressorType.ManagedBZip2: compressor = new BZ2ManagedCompressor();  break;

            default: throw new ArgumentOutOfRangeException("Unknown compressor typeId.");
            }
            return(compressor);
        }
Exemplo n.º 2
0
 public static ICompressor New(CompressorType typeId)
 {
     ICompressor compressor = null;
     switch (typeId) {
         case CompressorType.None        : compressor = new NoneCompressor();        break;
         case CompressorType.Zip         : try { compressor = new ZipNativeCompressor();  } 
                                         catch { compressor = new ZipManagedCompressor(); }   break;
         case CompressorType.BZip2       : try { compressor = new BZ2NativeCompressor();  } 
                                         catch { compressor = new BZ2ManagedCompressor(); }   break;
         case CompressorType.NativeZip   : compressor = new ZipNativeCompressor();   break;
         case CompressorType.ManagedZip  : compressor = new ZipManagedCompressor();  break;
         case CompressorType.NativeBZip2 : compressor = new BZ2NativeCompressor();   break;
         case CompressorType.ManagedBZip2: compressor = new BZ2ManagedCompressor();  break;
         default: throw new ArgumentOutOfRangeException("Unknown compressor typeId.");
     } return compressor;
 }