**** Merged from MCS ****
[mono-project.git] / mcs / class / System / System.Net.Mime / ContentType.cs
blob0382236c179b9a7e25d6dcb424ddadfbaf6b6c1d
1 //
2 // System.Net.Mail.ContentType.cs
3 //
4 // Author:
5 // Tim Coleman (tim@timcoleman.com)
6 //
7 // Copyright (C) Tim Coleman, 2004
8 //
11 // Permission is hereby granted, free of charge, to any person obtaining
12 // a copy of this software and associated documentation files (the
13 // "Software"), to deal in the Software without restriction, including
14 // without limitation the rights to use, copy, modify, merge, publish,
15 // distribute, sublicense, and/or sell copies of the Software, and to
16 // permit persons to whom the Software is furnished to do so, subject to
17 // the following conditions:
18 //
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
21 //
22 // THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
23 // EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
24 // MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
25 // NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
26 // LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
27 // OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
28 // WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
31 #if NET_2_0
33 using System.Collections.Specialized;
35 namespace System.Net.Mime {
36 public class ContentType
38 #region Fields
40 string contentType;
41 string boundary;
42 string charset;
43 string mediaType;
44 string name;
46 #endregion // Fields
48 #region Constructors
50 public ContentType ()
54 [MonoTODO ("Parse content type")]
55 public ContentType (string contentType)
57 this.contentType = contentType;
59 int index = contentType.IndexOf (";");
60 if (index > 0)
61 this.mediaType = contentType.Substring (0, index);
62 else
63 this.mediaType = contentType;
66 #endregion // Constructors
68 #region Properties
70 public string Boundary {
71 get { return boundary; }
72 set {
73 contentType = null;
74 boundary = value;
78 public string CharSet {
79 get { return charset; }
80 set {
81 contentType = null;
82 charset = value;
86 public string MediaType {
87 get { return mediaType; }
88 set {
89 contentType = null;
90 mediaType = value;
94 public string Name {
95 get { return name; }
96 set {
97 contentType = null;
98 name = value;
102 [MonoTODO]
103 public StringDictionary Parameters {
104 get {
105 throw new NotImplementedException ();
109 #endregion // Properties
111 #region Methods
113 [MonoTODO ("Fix this")]
114 public override string ToString ()
116 if (contentType != null)
117 return contentType;
118 string output = MediaType;
119 if (CharSet != null)
120 output += String.Format ("; charset={0}", CharSet);
121 if (Name != null)
122 output += String.Format ("; name={0}", Name);
123 if (Boundary != null)
124 output += String.Format ("; boundary={0}", Boundary);
125 return output;
128 #endregion // Methods
132 #endif // NET_2_0