Class WebContentType
Represents the media type for the content of a System.Net.WebRequest or System.Net.WebResponse.
Inheritance
Implements
Inherited Members
Namespace: Argotic.Net
Assembly: Argotic.Core.dll
Syntax
[Serializable]
public class WebContentType : IComparable
Remarks
See http://www.iana.org/assignments/media-types for a listing of the registered IANA MIME media types and sub-types.
Constructors
| Improve this Doc View SourceWebContentType()
Initializes a new instance of the WebContentType class.
Declaration
public WebContentType()
WebContentType(String, String)
Initializes a new instance of the WebContentType class using the specified media type and sub-type.
Declaration
public WebContentType(string mediaType, string mediaSubtype)
Parameters
Type | Name | Description |
---|---|---|
System.String | mediaType | The top-level media type used to declare the general type of data the media content represents. |
System.String | mediaSubtype | The specific format for the general type of data the media content represents |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The |
System.ArgumentNullException | The |
System.ArgumentNullException | The |
System.ArgumentNullException | The |
WebContentType(String, String, String)
Initializes a new instance of the WebContentType class using the specified media type, sub-type and type discriminator.
Declaration
public WebContentType(string mediaType, string mediaSubtype, string discriminator)
Parameters
Type | Name | Description |
---|---|---|
System.String | mediaType | The top-level media type used to declare the general type of data the media content represents. |
System.String | mediaSubtype | The specific format for the general type of data the media content represents |
System.String | discriminator | A string value that provides a means of discriminating the media content. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The |
System.ArgumentNullException | The |
System.ArgumentNullException | The |
System.ArgumentNullException | The |
WebContentType(String, String, String, Encoding)
Initializes a new instance of the WebContentType class using the specified media type, sub-type, type discriminator and character encoding.
Declaration
public WebContentType(string mediaType, string mediaSubtype, string discriminator, Encoding characterSet)
Parameters
Type | Name | Description |
---|---|---|
System.String | mediaType | The top-level media type used to declare the general type of data the media content represents. |
System.String | mediaSubtype | The specific format for the general type of data the media content represents |
System.String | discriminator | A string value that provides a means of discriminating the media content. |
System.Text.Encoding | characterSet | A Encoding object that represents the character encoding of the media content. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The |
System.ArgumentNullException | The |
System.ArgumentNullException | The |
System.ArgumentNullException | The |
System.ArgumentNullException | The |
Properties
| Improve this Doc View SourceCharacterSet
Gets or sets the character encoding of this media content.
Declaration
public string CharacterSet { get; set; }
Property Value
Type | Description |
---|---|
System.String | The name registered with the Internet Assigned Numbers Authority (IANA) for the character encoding of this media content. If no character encoding has been specified, returns System.String.Empty. |
Remarks
The CharacterSet property gets or sets the charset parameter within the Parameters collection. Specifiying System.String.Empty for the character encoding will remove the charset parameter from the Parameters collection.
Discriminator
Gets or sets the type discriminator of this media content.
Declaration
public string Discriminator { get; set; }
Property Value
Type | Description |
---|---|
System.String | A value that provides a means of discriminating this media content. If no type discriminator has been specified, returns System.String.Empty. |
Remarks
The Discriminator property gets or sets the type parameter within the Parameters collection. The type parameter can be used to discrimiate between resource representations that share the same MediaType and MediaSubtype. Specifiying System.String.Empty for the type discriminator will remove the type parameter from the Parameters collection.
Encoding
Gets the Encoding for the current CharacterSet.
Declaration
public Encoding Encoding { get; }
Property Value
Type | Description |
---|---|
System.Text.Encoding | A Encoding object that represents the character encoding of this media content. If the CharacterSet is not specified, a null reference (Nothing in Visual Basic) is returned. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The CharacterSet is not a valid code page name. |
System.ArgumentException | The code page indicated by CharacterSet is not supported by the underlying platform. |
MediaSubtype
Gets or sets the specific format for the general type of data this media content represents.
Declaration
public string MediaSubtype { get; set; }
Property Value
Type | Description |
---|---|
System.String | The specific format for the general type of data this media content represents. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The |
System.ArgumentNullException | The |
MediaType
Gets or sets the top-level media type used to declare the general type of data this media content represents.
Declaration
public string MediaType { get; set; }
Property Value
Type | Description |
---|---|
System.String | The top-level media type used to declare the general type of data this media content represents. |
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The |
System.ArgumentNullException | The |
Parameters
Gets the name/value pairs of additional parameters applied to this media content.
Declaration
public Dictionary<string, string> Parameters { get; }
Property Value
Type | Description |
---|---|
System.Collections.Generic.Dictionary<System.String, System.String> | A System.Collections.Generic.Dictionary<TKey, TValue> collection of strings that represents the name/value pairs of additional parameters applied to this media content. |
Remarks
The WebContentType class provides accessors for the commonly used type and charset parameters through the CharacterSet and Discriminator properties.
See Also
Methods
| Improve this Doc View SourceCompareSequence(Dictionary<String, String>, Dictionary<String, String>)
Compares two specified System.Collections.Generic.Dictionary<TKey, TValue> collections.
Declaration
public static int CompareSequence(Dictionary<string, string> source, Dictionary<string, string> target)
Parameters
Type | Name | Description |
---|---|---|
System.Collections.Generic.Dictionary<System.String, System.String> | source | The first collection. |
System.Collections.Generic.Dictionary<System.String, System.String> | target | The second collection. |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer indicating the lexical relationship between the two comparands. |
Remarks
If the collections contain the same number of elements, determines the lexical relationship between the two sequences of comparands.
If the source
has an element count that is greater than the target
element count, returns 1.
If the source
has an element count that is less than the target
element count, returns -1.
Exceptions
Type | Condition |
---|---|
System.ArgumentNullException | The |
System.ArgumentNullException | The |
CompareTo(Object)
Compares the current instance with another object of the same type.
Declaration
public int CompareTo(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | An object to compare with this instance. |
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer that indicates the relative order of the objects being compared. |
Exceptions
Type | Condition |
---|---|
System.ArgumentException | The |
Equals(Object)
Determines whether the specified System.Object is equal to the current instance.
Declaration
public override bool Equals(object obj)
Parameters
Type | Name | Description |
---|---|---|
System.Object | obj | The System.Object to compare with the current instance. |
Returns
Type | Description |
---|---|
System.Boolean | true if the specified System.Object is equal to the current instance; otherwise, false. |
Overrides
GetHashCode()
Returns a hash code for the current instance.
Declaration
public override int GetHashCode()
Returns
Type | Description |
---|---|
System.Int32 | A 32-bit signed integer hash code. |
Overrides
ToString()
Returns a System.String that represents the current WebContentType.
Declaration
public override string ToString()
Returns
Type | Description |
---|---|
System.String | A System.String that represents the current WebContentType. |
Overrides
Remarks
This method returns the MIME content type representation for the current instance.
Operators
| Improve this Doc View SourceEquality(WebContentType, WebContentType)
Determines if operands are equal.
Declaration
public static bool operator ==(WebContentType first, WebContentType second)
Parameters
Type | Name | Description |
---|---|---|
WebContentType | first | Operand to be compared. |
WebContentType | second | Operand to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | true if the values of its operands are equal, otherwise; false. |
GreaterThan(WebContentType, WebContentType)
Determines if first operand is greater than second operand.
Declaration
public static bool operator>(WebContentType first, WebContentType second)
Parameters
Type | Name | Description |
---|---|---|
WebContentType | first | Operand to be compared. |
WebContentType | second | Operand to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | true if the first operand is greater than the second, otherwise; false. |
Inequality(WebContentType, WebContentType)
Determines if operands are not equal.
Declaration
public static bool operator !=(WebContentType first, WebContentType second)
Parameters
Type | Name | Description |
---|---|---|
WebContentType | first | Operand to be compared. |
WebContentType | second | Operand to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | false if its operands are equal, otherwise; true. |
LessThan(WebContentType, WebContentType)
Determines if first operand is less than second operand.
Declaration
public static bool operator <(WebContentType first, WebContentType second)
Parameters
Type | Name | Description |
---|---|---|
WebContentType | first | Operand to be compared. |
WebContentType | second | Operand to compare to. |
Returns
Type | Description |
---|---|
System.Boolean | true if the first operand is less than the second, otherwise; false. |