4using System.Threading.Tasks;
15 private readonly
static Dictionary<string, bool> protectedContentTypes =
new Dictionary<string, bool>(StringComparer.OrdinalIgnoreCase);
16 private static string[] canConvertFrom =
null;
24 lock (protectedContentTypes)
26 protectedContentTypes[ContentType] =
true;
27 canConvertFrom =
null;
38 lock (protectedContentTypes)
40 return protectedContentTypes.TryGetValue(ContentType, out
bool Protected) && Protected;
58 string[] Result = canConvertFrom;
59 if (!(Result is
null))
67 if (!
IsProtected(ContentType) && Array.IndexOf(ZipTypes, ContentType) < 0)
68 Supported.Add(ContentType);
71 canConvertFrom = Result = Supported.ToArray();
99 if (
string.IsNullOrEmpty(SourceFileName))
104 using (MemoryStream Output =
new MemoryStream())
107 Data = Output.ToArray();
110 await State.
To.WriteAsync(Data, 0, Data.Length);
Contains the state of a content conversion process.
string FromContentType
Content type of the content to convert from.
Stream To
Stream pointing to where binary representation of content is to be sent.
string FromFileName
If the content is coming from a file, this parameter contains the name of that file....
Stream From
Stream pointing to binary representation of content.
Static class managing encoding and decoding of internet content.
static string GetFileExtension(string ContentType)
Gets the file extension of an item, given its content type. It uses the TryGetFileExtension to see if...
static string[] CanEncodeContentTypes
Internet content types that can be encoded.
Converts an object to a ZIP File.
string[] FromContentTypes
Converts content from these content types.
async Task< bool > ConvertAsync(ConversionState State)
Performs the actual conversion.
virtual Grade ConversionGrade
How well the content is converted.
ObjectToZipConverter()
Converts an object to a ZIP File.
static void ProtectContentType(string ContentType)
Protects a content type, so that it cannot be included in generated zip files by external parties thr...
string[] ToContentTypes
Converts content to these content types.
static bool IsProtected(string ContentType)
Checks if a Content-Type is protected.
ZIP File encoder/decoder.
static readonly string[] ZipFileContentTypes
ZIP File content types.
Static class for creating ZIP files.
static Task CreateZipFile(string SourceFileName, string OutputFileName)
Creates a ZIP file containing a single file.
A chunked list is a linked list of chunks of objects of type T .
Basic interface for Internet Content encoders. A class implementing this interface and having a defau...