PeterO.Mail.DataUris
## PeterO.Mail.DataUris
public static class DataUris
Contains methods for parsing and generating Data URIs (uniform resource identifiers). Data URIs are described in RFC 2397. Examples for Data URIs follow.
data:, hello%20world data:text/markdown, hello%20world data:application/octet-stream;base64, AAAAAA==
.
Member Summary
[DataUriBytes(string)](#DataUriBytes_string)
- Extracts the data from a Data URI (uniform resource identifier) in the form of a byte array.[DataUriBytes(System.Uri)](#DataUriBytes_System_Uri)
- Extracts the data from a Data URI (uniform resource identifier) in the form of a byte array, where the Data URI is given as a URI object.[DataUriMediaType(string)](#DataUriMediaType_string)
- Extracts the media type from a Data URI (uniform resource identifier) in the form of a text string.[DataUriMediaType(System.Uri)](#DataUriMediaType_System_Uri)
- Extracts the media type from a Data URI (uniform resource identifier) in the form of a URI object.[MakeDataUri(byte[], PeterO.Mail.MediaType)](#MakeDataUri_byte_PeterO_Mail_MediaType)
- Encodes data with the given media type in a Data URI (uniform resource identifier).[MakeDataUri(string)](#MakeDataUri_string)
- Encodes text as a Data URI (uniform resource identifier).
public static byte[] DataUriBytes( string uri);
Extracts the data from a Data URI (uniform resource identifier) in the form of a byte array.
Parameters:
- uri: The parameter uri is a text string.
Return Value:
The data as a byte array. Returns null if uri is null, is syntactically invalid, or is not a data URI.
Exceptions:
- System.ArgumentNullException: The parameter uri is null.
public static byte[] DataUriBytes( System.Uri uri);
Extracts the data from a Data URI (uniform resource identifier) in the form of a byte array, where the Data URI is given as a URI object.
Parameters:
- uri: The Data URI in the form of a URI object.
Return Value:
The data as a byte array. Returns null if uri is null, is syntactically invalid, or is not a data URI.
Exceptions:
- System.ArgumentNullException: The parameter uri is null.
public static PeterO.Mail.MediaType DataUriMediaType( string uri);
Extracts the media type from a Data URI (uniform resource identifier) in the form of a text string.
Parameters:
- uri: A data URI in the form of a text string.
Return Value:
The media type. Returns null if uri is null, is syntactically invalid, or is not a Data URI.
Exceptions:
- System.ArgumentNullException: The parameter uri is null.
public static PeterO.Mail.MediaType DataUriMediaType( System.Uri uri);
Extracts the media type from a Data URI (uniform resource identifier) in the form of a URI object.
Parameters:
- uri: A data URI in the form of a URI object.
Return Value:
The media type. Returns null if uri is null, is syntactically invalid, or is not a Data URI.
Exceptions:
- System.ArgumentNullException: The parameter uri is null.
public static string MakeDataUri( byte[] bytes, PeterO.Mail.MediaType mediaType);
Encodes data with the given media type in a Data URI (uniform resource identifier).
Parameters:
-
bytes: A byte array containing the data to encode in a Data URI.
-
mediaType: A media type to assign to the data.
Return Value:
A Data URI that encodes the given data and media type.
Exceptions:
- System.ArgumentNullException: The parameter bytes or mediaType is null.
public static string MakeDataUri( string textString);
Encodes text as a Data URI (uniform resource identifier).
Parameters:
- textString: A text string to encode as a data URI.
Return Value:
A Data URI that encodes the given text.
Exceptions:
- System.ArgumentNullException: The parameter textString is null.