merge -r 61110:61111
[mono.git] / mcs / class / System / System.Net.Mail / LinkedResource.cs
1 //
2 // System.Net.Mail.LinkedResource.cs
3 //
4 // Author:
5 //      John Luke (john.luke@gmail.com)
6 //
7 // Copyright (C) John Luke, 2005
8 //
9
10 //
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.
29 //
30
31 #if NET_2_0
32
33 using System.IO;
34 using System.Net.Mime;
35 using System.Text;
36
37 namespace System.Net.Mail {
38         public class LinkedResource : AttachmentBase
39         {
40                 #region Fields
41                 
42                 Uri contentLink;
43
44                 #endregion // Fields
45
46                 #region Constructors
47
48                 [MonoTODO]
49                 public LinkedResource (string fileName) : base (fileName)
50                 {
51                         if (fileName == null)
52                                 throw new ArgumentNullException ();
53                 }
54                 
55                 [MonoTODO]
56                 public LinkedResource (string fileName, ContentType contentType) : base (fileName, contentType)
57                 {
58                         if (fileName == null)
59                                 throw new ArgumentNullException ();
60                 }
61                 
62                 [MonoTODO]
63                 public LinkedResource (string fileName, string mediaType) : base (fileName, mediaType)
64                 {
65                         if (fileName == null)
66                                 throw new ArgumentNullException ();
67                 }
68
69                 [MonoTODO]
70                 public LinkedResource (Stream contentStream) : base (contentStream)
71                 {
72                         if (contentStream == null)
73                                 throw new ArgumentNullException ();
74                 }
75                 
76                 [MonoTODO]
77                 public LinkedResource (Stream contentStream, ContentType contentType) : base (contentStream, contentType)
78                 {
79                         if (contentStream == null)
80                                 throw new ArgumentNullException ();
81                 }
82                 
83                 [MonoTODO]
84                 public LinkedResource (Stream contentStream, string mediaType) : base (contentStream, mediaType)
85                 {
86                         if (contentStream == null)
87                                 throw new ArgumentNullException ();
88                 }
89
90                 #endregion // Constructors
91
92                 #region Properties
93
94                 public Uri ContentLink {
95                         get { return contentLink; }
96                         set { contentLink = value; }
97                 }
98
99                 #endregion // Properties
100
101                 #region Methods
102
103                 [MonoTODO]
104                 public static LinkedResource CreateLinkedResourceFromString (string content)
105                 {
106                         if (content == null)
107                                 throw new ArgumentNullException ();
108                         MemoryStream ms = new MemoryStream (Encoding.Default.GetBytes (content));
109                         return new LinkedResource (ms);
110                 }
111                 
112                 [MonoTODO]
113                 public static LinkedResource CreateLinkedResourceFromString (string content, ContentType contentType)
114                 {
115                         if (content == null)
116                                 throw new ArgumentNullException ();
117                         MemoryStream ms = new MemoryStream (Encoding.Default.GetBytes (content));
118                         return new LinkedResource (ms, contentType);
119                 }
120                 
121                 [MonoTODO]
122                 public static LinkedResource CreateLinkedResourceFromString (string content, Encoding contentEncoding, string mediaType)
123                 {
124                         if (content == null)
125                                 throw new ArgumentNullException ();
126                         MemoryStream ms = new MemoryStream (contentEncoding.GetBytes (content));
127                         return new LinkedResource (ms, mediaType);
128                 }
129
130                 #endregion // Methods
131         }
132 }
133
134 #endif // NET_2_0