private Compression(CompressionMethod method, int?level = null) { _value = method.ToString(); if (level.HasValue) { _value += string.Format("/{0}", level); } }
internal static string ToExtensionString(this CompressionMethod method, params string[] parameters) { if (method == CompressionMethod.None) { return(string.Empty); } var m = $"permessage-{method.ToString().ToLower()}"; return(parameters == null || parameters.Length == 0 ? m : $"{m}; {string.Join("; ", parameters)}"); }
public CompressedHttpContent(HttpContent content, CompressionMethod compressionMethod) { _originalContent = content ?? throw new ArgumentNullException(nameof(content)); _compressionMethod = compressionMethod; foreach (KeyValuePair <string, IEnumerable <string> > header in _originalContent.Headers) { Headers.TryAddWithoutValidation(header.Key, header.Value); } Headers.ContentEncoding.Add(_compressionMethod.ToString().ToLowerInvariant()); }
internal static string ToExtensionString(this CompressionMethod method, params string[] parameters) { if (method == CompressionMethod.None) { return(string.Empty); } string text = $"permessage-{method.ToString().ToLower()}"; if (parameters == null || parameters.Length == 0) { return(text); } return(string.Format("{0}; {1}", text, parameters.ToString("; "))); }
internal static string ToExtensionString( this CompressionMethod method, params string[] parameters ) { if (method == CompressionMethod.None) { return(string.Empty); } var name = $"permessage-{method.ToString().ToLower()}"; return(parameters != null && parameters.Length > 0 ? $"{name}; {parameters.ToString("; ")}" : name); }
public CompressedContent(HttpContent httpContent, CompressionMethod compressedMethod) { if (httpContent == null) { throw new ArgumentNullException(nameof(httpContent)); } _originalContent = httpContent; _compressionMethod = compressedMethod; foreach (KeyValuePair <string, IEnumerable <string> > item in _originalContent.Headers) { Headers.TryAddWithoutValidation(item.Key, item.Value); } Headers.ContentEncoding.Add(_compressionMethod.ToString()); }
internal static string ToExtensionString( this CompressionMethod method, params string[] parameters) { if (method == CompressionMethod.None) { return(String.Empty); } var m = String.Format("permessage-{0}", method.ToString().ToLower()); if (parameters == null || parameters.Length == 0) { return(m); } return(String.Format("{0}; {1}", m, parameters.ToString("; "))); }
public CompressedContent(HttpContent content, CompressionMethod compressionMethod) { if (compressionMethod == CompressionMethod.None) { throw new ArgumentException("Invalid CompressionMethod", nameof(compressionMethod)); } _originalContent = content ?? throw new ArgumentNullException(nameof(content)); _compressionMethod = compressionMethod; foreach (var header in _originalContent.Headers) { Headers.TryAddWithoutValidation(header.Key, header.Value); } Headers.ContentEncoding.Add(_compressionMethod.ToString().ToLowerInvariant()); }
private static void CreatePackageResource(string file = "") { if (string.IsNullOrEmpty(file)) { file = CommandLineActions.DestinationPath; CommandLineLogger.LogDebug($"Using destination path: {file}"); } PackageVersion packageVersion = CommandLineActions.PackageVersion; Dictionary <string, object> compressionOptions = CommandLineArguments.GetCompressionOptions(Path.GetExtension(file)?.ToLower() == ".lsv" ? "zlib" : Args.CompressionMethod, packageVersion); CompressionMethod compressionMethod = (CompressionMethod)compressionOptions["Compression"]; bool compressionSpeed = (bool)compressionOptions["FastCompression"]; CommandLineLogger.LogDebug($"Using compression method: {compressionMethod.ToString()}"); CommandLineLogger.LogDebug($"Using fast compression: {compressionSpeed}"); Packager packager = new Packager(); packager.CreatePackage(file, CommandLineActions.SourcePath, packageVersion, compressionMethod, compressionSpeed); CommandLineLogger.LogInfo("Package created successfully."); }
public Method(CompressionMethod method) : this() { Value = method.ToString(); }
internal static string ToExtensionString(this CompressionMethod method) { return((method == CompressionMethod.None) ? string.Empty : string.Format("permessage-{0}", method.ToString().ToLower())); }
public Method(CompressionMethod method) : this() { Value = method.ToString(); }
private static string createDeprecatedCompressionExtension(CompressionMethod method) { return method != CompressionMethod.NONE ? String.Format("permessage-compress; method={0}", method.ToString().ToLower()) : String.Empty; }
private Compression(CompressionMethod method, CompressionLevel level) { _value = method.ToString() + "/" + level.ToString(); }
public static CompressionModule FromKnownCompressionMethod(CompressionMethod method) { switch (method) { case CompressionMethod.None: return(new Modules.Store.StoreCompressionModule()); case CompressionMethod.Bzip2: return(new Modules.Bzip2.Bzip2CompressionModule()); case CompressionMethod.Deflate: return(new Modules.Deflate.DeflateCompressionModule()); case CompressionMethod.Gzip: return(new Modules.Gzip.GzipCompressionModule()); case CompressionMethod.LZSS: return(new Modules.LZSS.LZSSCompressionModule()); case CompressionMethod.LZRW1: return(new Modules.LZRW1.LZRW1CompressionModule()); case CompressionMethod.LZX: return(new Modules.LZX.LZXCompressionModule()); case CompressionMethod.XMemLZX: return(new Modules.XMemLZX.XMemLZXCompressionModule()); case CompressionMethod.Zlib: return(new Modules.Zlib.ZlibCompressionModule()); } throw new ArgumentException("Could not identify compression module for method " + method.ToString()); }
internal static string ToExtensionString(this CompressionMethod method) { return(method != CompressionMethod.None ? $"permessage-{method.ToString().ToLower()}" : string.Empty); }
public void SetMethod(CompressionMethod method) { if (!Enum.IsDefined(typeof(CompressionMethod), method)) { throw new InvalidEnumArgumentException(); } switch (this.KnownFormat) { case KnownSevenZipFormat.Xz: if (method != CompressionMethod.LZMA2) { throw new NotSupportedException(); } return; case KnownSevenZipFormat.Zip: switch (method) { case CompressionMethod.Copy: case CompressionMethod.LZMA: case CompressionMethod.PPMd: case CompressionMethod.BZip2: case CompressionMethod.Deflate: case CompressionMethod.Deflate64: this.Properties["m"] = method.ToString(); return; } break; case KnownSevenZipFormat.Tar: if (method != CompressionMethod.Copy) { throw new NotSupportedException(); } return; case KnownSevenZipFormat.SevenZip: switch (method) { case CompressionMethod.Copy: case CompressionMethod.LZMA: case CompressionMethod.LZMA2: case CompressionMethod.PPMd: case CompressionMethod.BZip2: this.Properties["0"] = method.ToString(); return; } throw new NotSupportedException(); case KnownSevenZipFormat.BZip2: if (method != CompressionMethod.BZip2) { throw new NotSupportedException(); } return; case KnownSevenZipFormat.GZip: if (method != CompressionMethod.Deflate) { throw new NotSupportedException(); } return; default: throw new NotSupportedException(); } throw new NotSupportedException(); }