2005-01-31 Zoltan Varga <vargaz@freemail.hu>
[mono.git] / mcs / class / System.XML / System.Xml.Serialization / XmlSerializerFactory.cs
1 // 
2 // System.Xml.Serialization.XmlSerializerFactory.cs 
3 //
4 // Author:
5 //   Lluis Sanchez Gual (lluis@ximian.com)
6 //
7 // Copyright (C) Novell, Inc., 2004
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;
34 using System.Collections;
35 using System.Security.Policy;
36
37 namespace System.Xml.Serialization 
38 {
39         public class XmlSerializerFactory
40         {
41                 static Hashtable serializersBySource = new Hashtable ();
42                 
43                 public XmlSerializerFactory ()
44                 {
45                 }
46
47                 public XmlSerializer CreateSerializer (Type type)
48                 {
49                         return CreateSerializer (type, null, null, null, null);
50                 }
51
52                 public XmlSerializer CreateSerializer (XmlTypeMapping xmlTypeMapping)
53                 {
54                         lock (serializersBySource) 
55                         {
56                                 XmlSerializer ser = (XmlSerializer) serializersBySource [xmlTypeMapping.Source];
57                                 if (ser == null) {
58                                         ser = new XmlSerializer (xmlTypeMapping);
59                                         serializersBySource [xmlTypeMapping.Source] = ser;
60                                 }
61                                 return ser;
62                         }
63                 }
64
65                 public XmlSerializer CreateSerializer (Type type, string defaultNamespace)
66                 {
67                         return CreateSerializer (type, null, null, null, defaultNamespace);
68                 }
69
70                 public XmlSerializer CreateSerializer (Type type, Type[] extraTypes)
71                 {
72                         return CreateSerializer (type, null, extraTypes, null, null);
73                 }
74
75                 public XmlSerializer CreateSerializer (Type type, XmlAttributeOverrides overrides)
76                 {
77                         return CreateSerializer (type, overrides, null, null, null);
78                 }
79
80                 public XmlSerializer CreateSerializer (Type type, XmlRootAttribute root)
81                 {
82                         return CreateSerializer (type, null, null, root, null);
83                 }
84                 
85                 public XmlSerializer CreateSerializer (Type type, 
86                         XmlAttributeOverrides overrides, 
87                         Type[] extraTypes, 
88                         XmlRootAttribute root, 
89                         string defaultNamespace)
90                 {
91                         XmlTypeSerializationSource source = new XmlTypeSerializationSource (type, root, overrides, defaultNamespace, extraTypes);
92                         lock (serializersBySource) 
93                         {
94                                 XmlSerializer ser = (XmlSerializer) serializersBySource [source];
95                                 if (ser == null) {
96                                         ser = new XmlSerializer (type, overrides, extraTypes, root, defaultNamespace);
97                                         serializersBySource [ser.Mapping.Source] = ser;
98                                 }
99                                 return ser;
100                         }
101                 }
102
103                 [MonoTODO]
104                 public XmlSerializer CreateSerializer (Type type, 
105                         XmlAttributeOverrides overrides, 
106                         Type[] extraTypes, 
107                         XmlRootAttribute root, 
108                         string defaultNamespace,
109                         string location,
110                         Evidence evidence)
111                 {
112                         throw new NotImplementedException ();
113                 }
114         }
115 }
116
117 #endif