Adding reference source for System.Net
[mono.git] / mcs / class / referencesource / System / net / System / Net / mail / AlternateView.cs
1 using System;
2 using System.IO;
3 using System.Net.Mime;
4 using System.Text;
5
6 namespace System.Net.Mail
7 {
8     public class AlternateView : AttachmentBase
9     {
10         private LinkedResourceCollection linkedResources;
11
12         internal AlternateView() 
13         { }
14
15
16         public AlternateView(string fileName) :
17             base(fileName)
18         { }
19
20         public AlternateView(string fileName, string mediaType) :
21             base(fileName, mediaType)
22         { }
23
24         public AlternateView(string fileName, ContentType contentType) :
25             base(fileName, contentType)
26         { }
27
28         public AlternateView(Stream contentStream) :
29             base(contentStream)
30         { }
31
32         public AlternateView(Stream contentStream, string mediaType) :
33             base(contentStream, mediaType)
34         { }
35
36         public AlternateView(Stream contentStream, ContentType contentType) :
37             base(contentStream, contentType)
38         { }
39
40         public LinkedResourceCollection LinkedResources
41         {
42             get
43             {
44                 if (disposed) {
45                     throw new ObjectDisposedException(this.GetType().FullName);
46                 }
47
48
49                 if (linkedResources == null)
50                 {
51                     linkedResources = new LinkedResourceCollection();
52                 }
53                 return linkedResources;
54             }
55         }
56
57         public Uri BaseUri
58         {
59             get
60             {
61                 return ContentLocation;
62             }
63
64             set
65             {
66                 ContentLocation = value;
67             }
68         }
69
70         public static AlternateView CreateAlternateViewFromString(string content){
71             AlternateView a = new AlternateView();
72             a.SetContentFromString(content, null, String.Empty);
73             return a;
74         }
75
76         public static AlternateView CreateAlternateViewFromString(string content, Encoding contentEncoding, string mediaType){
77             AlternateView a = new AlternateView();
78             a.SetContentFromString(content, contentEncoding, mediaType);
79             return a;
80         }
81
82         public static AlternateView CreateAlternateViewFromString(string content, ContentType contentType){
83             AlternateView a = new AlternateView();
84             a.SetContentFromString(content, contentType);
85             return a;
86         }
87
88         protected override void Dispose(bool disposing)
89         {
90             if(disposed){
91                 return;
92             }
93
94             if (disposing && linkedResources != null)
95             {
96                 linkedResources.Dispose();
97             }
98             base.Dispose(disposing);
99         }
100     }
101 }