forked from ServiceStack/ServiceStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCompressionTypes.cs
More file actions
40 lines (35 loc) · 1.22 KB
/
CompressionTypes.cs
File metadata and controls
40 lines (35 loc) · 1.22 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
using System;
namespace ServiceStack.Common.Web
{
public static class CompressionTypes
{
public static readonly string[] AllCompressionTypes = new[] { Deflate, GZip };
public const string Default = Deflate;
public const string Deflate = "deflate";
public const string GZip = "gzip";
public static bool IsValid(string compressionType)
{
return compressionType == Deflate || compressionType == GZip;
}
public static void AssertIsValid(string compressionType)
{
if (!IsValid(compressionType))
{
throw new NotSupportedException(compressionType
+ " is not a supported compression type. Valid types: gzip, deflate.");
}
}
public static string GetExtension(string compressionType)
{
switch (compressionType)
{
case Deflate:
case GZip:
return "." + compressionType;
default:
throw new NotSupportedException(
"Unknown compressionType: " + compressionType);
}
}
}
}