PeterO.Mail.MediaTypeBuilder
## PeterO.Mail.MediaTypeBuilder
public sealed class MediaTypeBuilder
Deprecated. Use MediaType.Builder instead.
A mutable media type object.
Member Summary
[IsMultipart](#IsMultipart)
- Deprecated: Instead of using this property, use the TopLevelType property and compare the result with the exact string ‘multipart’.[IsText](#IsText)
- Deprecated: Instead of using this property, use the TopLevelType property and compare the result with the exact string ‘text’.[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.
### MediaTypeBuilder Constructor
public MediaTypeBuilder( PeterO.Mail.MediaType mt);
Initializes a new instance of the PeterO.Mail.MediaTypeBuilder 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.
### MediaTypeBuilder Constructor
public MediaTypeBuilder( string type, string subtype);
Initializes a new instance of the PeterO.Mail.MediaTypeBuilder class.
Parameters:
-
type: The media type’s top-level type.
-
subtype: The media type’s subtype.
### MediaTypeBuilder Constructor
public MediaTypeBuilder();
Initializes a new instance of the PeterO.Mail.MediaTypeBuilder class, using the type “application/octet-stream” .
public bool IsMultipart { get; }
Deprecated. Instead of using this property, use the TopLevelType property and compare the result with the exact string ‘multipart’.
Gets a value indicating whether this is a multipart media type.
Returns:
true
If this is a multipart media type; otherwise, false
.
public bool IsText { get; }
Deprecated. Instead of using this property, use the TopLevelType property and compare the result with the exact string ‘text’.
Gets a value indicating whether this is a text media type.
Returns:
true
If this is a text media type; otherwise, false
.
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.MediaTypeBuilder 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.MediaTypeBuilder 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.MediaTypeBuilder 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.MediaTypeBuilder 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.