PeterO.Mail.MediaType.Builder
## PeterO.Mail.MediaType.Builder
public sealed class Builder
A mutable data type that allows a media type object to be built.
Member Summary
[RemoveParameter(string)](#RemoveParameter_string)
- Removes a parameter from this builder object.[SetParameter(string, string)](#SetParameter_string_string)
- Sets a parameter’s name and value for this media type.[SetSubType(string)](#SetSubType_string)
- Sets this media type’s subtype, such as “plain” or “xml” .[SetTopLevelType(string)](#SetTopLevelType_string)
- Sets this media type’s top-level type.[SubType](#SubType)
- Gets or sets this value’s subtype.[ToMediaType()](#ToMediaType)
- Converts this builder to an immutable media type object.[TopLevelType](#TopLevelType)
- Gets or sets this value’s top-level type.[ToString()](#ToString)
- Converts this object to a text string of the media type it represents, in the same form as MediaType.
public Builder( PeterO.Mail.MediaType mt);
Initializes a new instance of the PeterO.Mail.MediaType.Builder class using the data from another media type.
Parameters:
- mt: The parameter mt is a MediaType object.
Exceptions:
- System.ArgumentNullException: The parameter mt is null.
public Builder( string type, string subtype);
Initializes a new instance of the PeterO.Mail.MediaType.Builder class.
Parameters:
-
type: The media type’s top-level type.
-
subtype: The media type’s subtype.
public Builder();
Initializes a new instance of the PeterO.Mail.MediaType.Builder class, using the type “application/octet-stream” .
public string SubType { get; set; }
Gets or sets this value’s subtype.
Returns:
A text string naming this object’s subtype, such as “plain” or “xml”.
Exceptions:
-
System.ArgumentNullException: The property is being set and the value is null.
-
System.ArgumentException: The property is being set and the value is syntactically invalid for a subtype.
public string TopLevelType { get; set; }
Gets or sets this value’s top-level type.
Returns:
A text string naming this object’s top-level type, such as “text” or “audio” .
Exceptions:
-
System.ArgumentNullException: The property is being set and the value is null.
-
System.ArgumentException: The property is being set and the value is syntactically invalid for a top-level type.
public PeterO.Mail.MediaType.Builder RemoveParameter( string name);
Removes a parameter from this builder object. Does nothing if the parameter’s name doesn’t exist.
Parameters:
- name: Name of the parameter to remove. The name is compared using a basic case-insensitive comparison. (Two strings are equal in such a comparison, if they match after converting the basic upper-case letters A to Z (U+0041 to U+005A) in both strings to basic lower-case letters.).
Return Value:
This instance.
Exceptions:
- System.ArgumentNullException: The parameter name is null.
public PeterO.Mail.MediaType.Builder SetParameter( string name, string value);
Sets a parameter’s name and value for this media type.
Parameters:
-
name: Name of the parameter to set, such as “charset” . The name is compared using a basic case-insensitive comparison. (Two strings are equal in such a comparison, if they match after converting the basic upper-case letters A to Z (U+0041 to U+005A) in both strings to basic lower-case letters.).
-
value: A text string giving the parameter’s value.
Return Value:
This instance.
Exceptions:
-
System.ArgumentNullException: The parameter value or name is null.
-
System.ArgumentException: The parameter name is empty or syntactically invalid.
public PeterO.Mail.MediaType.Builder SetSubType( string str);
Sets this media type’s subtype, such as “plain” or “xml” . This method enables the pattern of method chaining (e.g., new...().Set...().Set...()
) unlike with the SubType property in.NET or the setSubType method (with small s) in Java.
Parameters:
- str: A text string naming a media subtype.
Return Value:
This instance.
Exceptions:
-
System.ArgumentNullException: The parameter str is null.
-
System.ArgumentException: The parameter str is empty or syntactically invalid.
public PeterO.Mail.MediaType.Builder SetTopLevelType( string str);
Sets this media type’s top-level type. This method enables the pattern of method chaining (e.g., new...().Set...().Set...()
) unlike with the TopLevelType property in.NET or the setTopLevelType method (with small s) in Java.
Parameters:
- str: A text string naming a top-level type, such as “text” or “audio” .
Return Value:
This instance.
Exceptions:
-
System.ArgumentNullException: The parameter str is null.
-
System.ArgumentException: The parameter str is syntactically invalid for a top-level type.
public PeterO.Mail.MediaType ToMediaType();
Converts this builder to an immutable media type object.
Return Value:
A MediaType object.
public override string ToString();
Converts this object to a text string of the media type it represents, in the same form as MediaType.ToString
.
Return Value:
A string representation of this object.