(DISTFILES): Comment out a few missing files.
[mono-project.git] / mcs / class / System.XML / System.Xml.Serialization / SerializationCodeGeneratorConfiguration.cs
blob7f05e6b5ce957c3010ccea562639bdeaa65d71a0
1 //
2 // System.Xml.Serialization.SerializationCodeGeneratorConfiguration.cs:
3 //
4 // Author:
5 // Lluis Sanchez Gual (lluis@ximian.com)
6 //
7 // (C) 2002, 2003 Ximian, Inc. http://www.ximian.com
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 using System;
32 using System.Collections;
33 using System.Xml.Serialization;
35 namespace System.Xml.Serialization
37 [XmlType ("configuration")]
38 internal class SerializationCodeGeneratorConfiguration
40 [XmlElement ("serializer")]
41 public SerializerInfo[] Serializers;
44 [XmlType ("serializer")]
45 internal class SerializerInfo
47 [XmlAttribute ("class")]
48 public string ClassName;
50 [XmlAttribute ("assembly")]
51 public string Assembly;
53 [XmlElement ("reader")]
54 public string ReaderClassName;
56 [XmlElement ("writer")]
57 public string WriterClassName;
59 [XmlElement ("namespace")]
60 public string Namespace;
62 [XmlArray ("namespaceImports")]
63 [XmlArrayItem ("namespaceImport")]
64 public string [] NamespaceImports;
66 [System.ComponentModel.DefaultValue (SerializationFormat.Literal)]
67 public SerializationFormat SerializationFormat = SerializationFormat.Literal;
69 [XmlElement ("outFileName")]
70 public string OutFileName;
72 [XmlArray ("readerHooks")]
73 public Hook[] ReaderHooks;
75 [XmlArray ("writerHooks")]
76 public Hook[] WriterHooks;
78 public ArrayList GetHooks (HookType hookType, HookDir dir, HookAction action, Type type, string member)
80 if (dir == HookDir.Read)
81 return FindHook (ReaderHooks, hookType, action, type, member);
82 else
83 return FindHook (WriterHooks, hookType, action, type, member);
86 ArrayList FindHook (Hook[] hooks, HookType hookType, HookAction action, Type type, string member)
88 ArrayList foundHooks = new ArrayList ();
89 if (hooks == null) return foundHooks;
91 foreach (Hook hook in hooks)
93 if (action == HookAction.InsertBefore && (hook.InsertBefore == null || hook.InsertBefore == ""))
94 continue;
95 else if (action == HookAction.InsertAfter && (hook.InsertAfter == null || hook.InsertAfter == ""))
96 continue;
97 else if (action == HookAction.Replace && (hook.Replace == null || hook.Replace == ""))
98 continue;
100 if (hook.HookType != hookType)
101 continue;
103 if (hook.Select != null)
105 if (hook.Select.TypeName != null && hook.Select.TypeName != "")
106 if (hook.Select.TypeName != type.FullName) continue;
108 if (hook.Select.TypeMember != null && hook.Select.TypeMember != "")
109 if (hook.Select.TypeMember != member) continue;
111 if (hook.Select.TypeAttributes != null && hook.Select.TypeAttributes.Length > 0)
113 object[] ats = type.GetCustomAttributes (true);
114 bool found = false;
115 foreach (object at in ats)
116 if (Array.IndexOf (hook.Select.TypeAttributes, at.GetType().FullName) != -1) { found = true; break; }
117 if (!found) continue;
120 foundHooks.Add (hook);
122 return foundHooks;
126 [XmlType ("hook")]
127 internal class Hook
129 [XmlAttribute ("type")]
130 public HookType HookType;
132 [XmlElement ("select")]
133 public Select Select;
135 [XmlElement ("insertBefore")]
136 public string InsertBefore;
138 [XmlElement ("insertAfter")]
139 public string InsertAfter;
141 [XmlElement ("replace")]
142 public string Replace;
144 public string GetCode (HookAction action)
146 if (action == HookAction.InsertBefore)
147 return InsertBefore;
148 else if (action == HookAction.InsertAfter)
149 return InsertAfter;
150 else
151 return Replace;
155 [XmlType ("select")]
156 internal class Select
158 [XmlElement ("typeName")]
159 public string TypeName;
161 [XmlElement("typeAttribute")]
162 public string[] TypeAttributes;
164 [XmlElement ("typeMember")]
165 public string TypeMember;
168 internal enum HookDir
170 Read,
171 Write
174 internal enum HookAction
176 InsertBefore,
177 InsertAfter,
178 Replace
181 [XmlType ("hookType")]
182 internal enum HookType
184 attributes,
185 elements,
186 unknownAttribute,
187 unknownElement,
188 member,
189 type