2 // System.Net.Mail.AlternateView.cs
5 // John Luke (john.luke@gmail.com)
7 // Copyright (C) John Luke, 2005
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:
19 // The above copyright notice and this permission notice shall be
20 // included in all copies or substantial portions of the Software.
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.
34 using System.Net.Mime;
37 namespace System.Net.Mail {
38 public class AlternateView : AttachmentBase
42 LinkedResourceCollection linkedResources = new LinkedResourceCollection ();
49 public AlternateView (string fileName) : base (fileName)
52 throw new ArgumentNullException ();
56 public AlternateView (string fileName, ContentType contentType) : base (fileName, contentType)
59 throw new ArgumentNullException ();
63 public AlternateView (string fileName, string mediaType) : base (fileName, mediaType)
66 throw new ArgumentNullException ();
70 public AlternateView (Stream contentStream) : base (contentStream)
72 if (contentStream == null)
73 throw new ArgumentNullException ();
77 public AlternateView (Stream contentStream, string mediaType) : base (contentStream, mediaType)
79 if (contentStream == null)
80 throw new ArgumentNullException ();
84 public AlternateView (Stream contentStream, ContentType contentType) : base (contentStream, contentType)
86 if (contentStream == null)
87 throw new ArgumentNullException ();
90 #endregion // Constructors
94 #endregion // Properties
97 get { return baseUri; }
98 set { baseUri = value; }
101 public LinkedResourceCollection LinkedResources {
102 get { return linkedResources; }
108 public static AlternateView CreateAlternateViewFromString (string content)
111 throw new ArgumentNullException ();
112 MemoryStream ms = new MemoryStream (Encoding.UTF8.GetBytes (content));
113 return new AlternateView (ms);
117 public static AlternateView CreateAlternateViewFromString (string content, ContentType contentType)
120 throw new ArgumentNullException ();
121 MemoryStream ms = new MemoryStream (Encoding.UTF8.GetBytes (content));
122 return new AlternateView (ms, contentType);
126 public static AlternateView CreateAlternateViewFromString (string content, Encoding encoding, string mediaType)
129 throw new ArgumentNullException ();
130 MemoryStream ms = new MemoryStream (encoding.GetBytes (content));
131 return new AlternateView (ms, mediaType);
135 protected override void Dispose (bool disposing)
137 base.Dispose (disposing);
140 #endregion // Methods