Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@ -0,0 +1 @@
6300882155a6a2ba38e14b5e3aaf03f751473d41

View File

@ -0,0 +1,53 @@
//
// System.Xml.Serialization.CodeExporter.cs
//
// Author:
// Lluis Sanchez Gual (lluis@novell.com)
//
// Copyright (C) Novell, Inc., 2004
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.CodeDom;
namespace System.Xml.Serialization
{
public abstract class CodeExporter
{
internal MapCodeGenerator codeGenerator;
internal CodeExporter ()
{
}
public CodeAttributeDeclarationCollection IncludeMetadata
{
get { return codeGenerator.IncludeMetadata; }
}
}
}
#endif

View File

@ -0,0 +1,58 @@
//
// System.Xml.Serialization.CodeGenerationOptions
//
// Author:
// Lluis Sanchez Gual (lluis@ximian.com)
//
// Copyright (C) Novell, Inc., 2004
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
namespace System.Xml.Serialization
{
[Flags]
#if NET_2_0
public
#else
[Serializable]
internal
#endif
enum CodeGenerationOptions
{
[XmlIgnore]
None = 0,
[XmlEnum ("properties")]
GenerateProperties = 1,
[XmlEnum ("newAsync")]
GenerateNewAsync = 2,
[XmlEnum ("oldAsync")]
GenerateOldAsync = 4,
[XmlEnum ("order")]
GenerateOrder = 8,
[XmlEnum ("enableDataBinding")]
EnableDataBinding = 16,
}
}

View File

@ -0,0 +1,79 @@
//
// System.Xml.Serialization.CodeIdentifier.cs
//
// Author:
// Tim Coleman (tim@timcoleman.com)
//
// Copyright (C) Tim Coleman, 2002
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Globalization;
namespace System.Xml.Serialization {
public class CodeIdentifier {
#if NET_2_0
[Obsolete ("Design mistake. It only contains static methods.")]
#endif
public
CodeIdentifier ()
{
}
public static string MakeCamel (string identifier)
{
string validIdentifier = MakeValid (identifier);
return (Char.ToLower (validIdentifier[0], CultureInfo.InvariantCulture) + validIdentifier.Substring (1));
}
public static string MakePascal (string identifier)
{
string validIdentifier = MakeValid (identifier);
return (Char.ToUpper (validIdentifier[0], CultureInfo.InvariantCulture) + validIdentifier.Substring (1));
}
public static string MakeValid (string identifier)
{
if (identifier == null)
throw new NullReferenceException ();
if (identifier.Length == 0)
return "Item";
string output = "";
if (!Char.IsLetter (identifier[0]) && (identifier[0]!='_') )
output = "Item";
foreach (char c in identifier)
if (Char.IsLetterOrDigit (c) || c == '_')
output += c;
if (output.Length > 400)
output = output.Substring (0,400);
return output;
}
}
}

View File

@ -0,0 +1,152 @@
//
// System.Xml.Serialization.CodeIdentifiers
//
// Author:
// Tim Coleman (tim@timcoleman.com)
//
// Copyright (C) Tim Coleman, 2002
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.Globalization;
namespace System.Xml.Serialization {
public class CodeIdentifiers {
#region Fields
bool useCamelCasing;
Hashtable table;
Hashtable reserved;
#endregion
#region Constructors
public CodeIdentifiers ()
: this (true)
{
}
#if NET_2_0
public
#else
private
#endif
CodeIdentifiers (bool caseSensitive)
{
#if NET_2_0
StringComparer c = caseSensitive ?
StringComparer.Ordinal :
StringComparer.OrdinalIgnoreCase;
table = new Hashtable (c);
reserved = new Hashtable (c);
#else
table = new Hashtable ();
reserved = new Hashtable ();
#endif
}
#endregion // Constructors
#region Properties
public bool UseCamelCasing {
get { return useCamelCasing; }
set { useCamelCasing = value; }
}
#endregion // Properties
#region Methods
public void Add (string identifier, object value)
{
table.Add (identifier, value);
}
public void AddReserved (string identifier)
{
reserved.Add (identifier, identifier);
}
public string AddUnique (string identifier, object value)
{
string unique = MakeUnique (identifier);
Add (unique, value);
return unique;
}
public void Clear ()
{
table.Clear ();
}
public bool IsInUse (string identifier)
{
return (table.ContainsKey (identifier) || reserved.ContainsKey (identifier));
}
public string MakeRightCase (string identifier)
{
if (UseCamelCasing)
return CodeIdentifier.MakeCamel (identifier);
else
return CodeIdentifier.MakePascal (identifier);
}
public string MakeUnique (string identifier)
{
string uniqueIdentifier = identifier;
int i = 1;
while (IsInUse (uniqueIdentifier)) {
uniqueIdentifier = String.Format (CultureInfo.InvariantCulture, "{0}{1}", identifier, i);
i += 1;
}
return uniqueIdentifier;
}
public void Remove (string identifier)
{
table.Remove (identifier);
}
public void RemoveReserved (string identifier)
{
reserved.Remove (identifier);
}
public object ToArray (Type type)
{
Array list = Array.CreateInstance (type, table.Count);
table.CopyTo (list, 0);
return list;
}
#endregion // Methods
}
}

View File

@ -0,0 +1,40 @@
//
// System.Xml.Serialization.IXmlSerializable.cs
//
// Author:
// Tim Coleman (tim@timcoleman.com)
//
// Copyright (C) Tim Coleman, 2002
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Xml.Schema;
namespace System.Xml.Serialization {
public interface IXmlSerializable {
XmlSchema GetSchema ();
void ReadXml (XmlReader reader);
void WriteXml (XmlWriter writer);
}
}

View File

@ -0,0 +1,42 @@
//
// System.Xml.Serialization.IXmlTextParser.cs
//
// Author:
// Lluis Sanchez Gual (lluis@ximian.com)
//
// Copyright (C) Novell, Inc., 2004
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
namespace System.Xml.Serialization
{
public interface IXmlTextParser
{
bool Normalized {get; set;}
WhitespaceHandling WhitespaceHandling {get; set;}
}
}
#endif

View File

@ -0,0 +1,78 @@
//
// System.Xml.Serialization.ImportContext.cs
//
// Author:
// Lluis Sanchez Gual (lluis@ximian.com)
//
// Copyright (C) Novell, Inc., 2004
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
using System.Collections;
using System.Collections.Specialized;
namespace System.Xml.Serialization
{
public class ImportContext
{
bool _shareTypes;
CodeIdentifiers _typeIdentifiers;
StringCollection _warnings = new StringCollection ();
internal Hashtable MappedTypes;
internal Hashtable DataMappedTypes;
internal Hashtable SharedAnonymousTypes;
public ImportContext (CodeIdentifiers identifiers, bool shareTypes)
{
_typeIdentifiers = identifiers;
this._shareTypes = shareTypes;
if (shareTypes) {
MappedTypes = new Hashtable ();
DataMappedTypes = new Hashtable ();
SharedAnonymousTypes = new Hashtable ();
}
}
public bool ShareTypes
{
get { return _shareTypes; }
}
public CodeIdentifiers TypeIdentifiers
{
get { return _typeIdentifiers; }
}
public StringCollection Warnings
{
get { return _warnings; }
}
}
}
#endif

View File

@ -0,0 +1,80 @@
//
// System.Xml.Serialization.KeyHelper.cs
//
// Author:
// Lluis Sanchez Gual (lluis@ximian.com)
//
// Copyright (C) 2004 Novell, Inc.
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.Globalization;
using System.Text;
namespace System.Xml.Serialization
{
internal class KeyHelper
{
public static void AddField (StringBuilder sb, int n, string val)
{
AddField (sb, n, val, null);
}
public static void AddField (StringBuilder sb, int n, string val, string def)
{
if (val != def) {
sb.Append (n.ToString());
sb.Append (val.Length.ToString(CultureInfo.InvariantCulture));
sb.Append (val);
}
}
public static void AddField (StringBuilder sb, int n, bool val)
{
AddField (sb, n, val, false);
}
public static void AddField (StringBuilder sb, int n, bool val, bool def)
{
if (val != def)
sb.Append (n.ToString());
}
public static void AddField (StringBuilder sb, int n, int val, int def)
{
if (val != def) {
sb.Append (n.ToString());
sb.Append (val.ToString(CultureInfo.InvariantCulture));
}
}
public static void AddField (StringBuilder sb, int n, Type val)
{
if (val != null) {
sb.Append (n.ToString(CultureInfo.InvariantCulture));
sb.Append (val.ToString());
}
}
}
}

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,127 @@
//
// System.Xml.Serialization.ReflectionHelper
//
// Author:
// Lluis Sanchez Gual (lluis@ximian.com)
//
// Copyright (C) 2003 Ximian, Inc.
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Reflection;
using System.Collections;
namespace System.Xml.Serialization
{
internal class ReflectionHelper
{
Hashtable _clrTypes = new Hashtable ();
Hashtable _schemaTypes = new Hashtable ();
public void RegisterSchemaType (XmlTypeMapping map, string xmlType, string ns)
{
string mapKey = xmlType + "/" + ns;
if (!_schemaTypes.ContainsKey (mapKey))
_schemaTypes.Add (mapKey, map);
}
public XmlTypeMapping GetRegisteredSchemaType (string xmlType, string ns)
{
string mapKey = xmlType + "/" + ns;
return _schemaTypes[mapKey] as XmlTypeMapping;
}
public void RegisterClrType (XmlTypeMapping map, Type type, string ns)
{
if (type == typeof(object)) ns = "";
string mapKey = type.FullName + "/" + ns;
if (!_clrTypes.ContainsKey (mapKey))
_clrTypes.Add (mapKey, map);
}
public XmlTypeMapping GetRegisteredClrType (Type type, string ns)
{
if (type == typeof(object)) ns = "";
string mapKey = type.FullName + "/" + ns;
return _clrTypes[mapKey] as XmlTypeMapping;
}
public Exception CreateError (XmlTypeMapping map, string message)
{
return new InvalidOperationException ("There was an error reflecting '" + map.TypeFullName + "': " + message);
}
#if NET_2_0
static readonly ParameterModifier [] empty_modifiers = new ParameterModifier [0];
#endif
public static void CheckSerializableType (Type type, bool allowPrivateConstructors)
{
if (type.IsArray) return;
#if NET_2_0
if (!allowPrivateConstructors && type.GetConstructor (BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance, null, Type.EmptyTypes, empty_modifiers) == null && !type.IsAbstract && !type.IsValueType)
#else
if (!allowPrivateConstructors && type.GetConstructor (Type.EmptyTypes) == null && !type.IsAbstract && !type.IsValueType)
#endif
throw new InvalidOperationException (type.FullName + " cannot be serialized because it does not have a default public constructor");
if (type.IsInterface && !TypeTranslator.GetTypeData (type).IsListType)
throw new InvalidOperationException (type.FullName + " cannot be serialized because it is an interface");
Type t = type;
Type oldt = null;
do {
if (!t.IsPublic && !t.IsNestedPublic)
throw new InvalidOperationException (type.FullName + " is inaccessible due to its protection level. Only public types can be processed");
oldt = t;
t = t.DeclaringType;
}
while (t != null && t != oldt);
}
public static string BuildMapKey (Type type)
{
return type.FullName + "::";
}
public static string BuildMapKey (MethodInfo method, string tag)
{
string res = method.DeclaringType.FullName + ":" + method.ReturnType.FullName + " " + method.Name + "(";
ParameterInfo[] pars = method.GetParameters ();
for (int n=0; n<pars.Length; n++)
{
if (n > 0) res += ", ";
res += pars[n].ParameterType.FullName;
}
res += ")";
if (tag != null)
res += ":" + tag;
return res;
}
}
}

View File

@ -0,0 +1,59 @@
//
// System.Xml.Serialization.SchemaImporter.cs
//
// Author:
// Lluis Sanchez Gual (lluis@novell.com)
//
// Copyright (C) Novell, Inc., 2004
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
#if NET_2_0
using System;
#if !TARGET_JVM
using System.Xml.Serialization.Advanced;
#endif
namespace System.Xml.Serialization
{
public abstract class SchemaImporter
{
SchemaImporterExtensionCollection extensions;
internal SchemaImporter ()
{
}
public SchemaImporterExtensionCollection Extensions
{
get {
if (extensions == null)
extensions = new SchemaImporterExtensionCollection ();
return extensions;
}
}
}
}
#endif

View File

@ -0,0 +1,44 @@
//
// System.Xml.Serialization.SchemaTypes
//
// Authors:
// Gonzalo Paniagua Javier (gonzalo@ximian.com)
//
// (C) 2002 Ximian, Inc (http://www.ximian.com)
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
namespace System.Xml.Serialization
{
internal enum SchemaTypes {
NotSet = 0,
Primitive,
Enum,
Array,
Class,
XmlSerializable,
XmlNode,
Void
}
}

View File

@ -0,0 +1 @@
86c63bc66a229be12e357a6bdb66bfffaf2ccf23

View File

@ -0,0 +1,202 @@
//
// System.Xml.Serialization.SerializationCodeGeneratorConfiguration.cs:
//
// Author:
// Lluis Sanchez Gual (lluis@ximian.com)
//
// (C) 2002, 2003 Ximian, Inc. http://www.ximian.com
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
using System.Xml.Serialization;
namespace System.Xml.Serialization
{
[XmlType ("configuration")]
internal class SerializationCodeGeneratorConfiguration
{
[XmlElement ("serializer")]
public SerializerInfo[] Serializers;
}
[XmlType ("serializer")]
internal class SerializerInfo
{
[XmlAttribute ("class")]
public string ClassName;
[XmlAttribute ("assembly")]
public string Assembly;
[XmlElement ("reader")]
public string ReaderClassName;
[XmlElement ("writer")]
public string WriterClassName;
[XmlElement ("baseSerializer")]
public string BaseSerializerClassName;
[XmlElement ("implementation")]
public string ImplementationClassName;
[XmlElement ("noreader")]
public bool NoReader;
[XmlElement ("nowriter")]
public bool NoWriter;
[XmlElement ("generateAsInternal")]
public bool GenerateAsInternal;
[XmlElement ("namespace")]
public string Namespace;
[XmlArray ("namespaceImports")]
[XmlArrayItem ("namespaceImport")]
public string [] NamespaceImports;
[System.ComponentModel.DefaultValue (SerializationFormat.Literal)]
public SerializationFormat SerializationFormat = SerializationFormat.Literal;
[XmlElement ("outFileName")]
public string OutFileName;
[XmlArray ("readerHooks")]
public Hook[] ReaderHooks;
[XmlArray ("writerHooks")]
public Hook[] WriterHooks;
public ArrayList GetHooks (HookType hookType, XmlMappingAccess dir, HookAction action, Type type, string member)
{
if ((dir & XmlMappingAccess.Read) != 0)
return FindHook (ReaderHooks, hookType, action, type, member);
if ((dir & XmlMappingAccess.Write) != 0)
return FindHook (WriterHooks, hookType, action, type, member);
else
throw new Exception ("INTERNAL ERROR");
}
ArrayList FindHook (Hook[] hooks, HookType hookType, HookAction action, Type type, string member)
{
ArrayList foundHooks = new ArrayList ();
if (hooks == null) return foundHooks;
foreach (Hook hook in hooks)
{
if (action == HookAction.InsertBefore && (hook.InsertBefore == null || hook.InsertBefore == ""))
continue;
else if (action == HookAction.InsertAfter && (hook.InsertAfter == null || hook.InsertAfter == ""))
continue;
else if (action == HookAction.Replace && (hook.Replace == null || hook.Replace == ""))
continue;
if (hook.HookType != hookType)
continue;
if (hook.Select != null)
{
if (hook.Select.TypeName != null && hook.Select.TypeName != "")
if (hook.Select.TypeName != type.FullName) continue;
if (hook.Select.TypeMember != null && hook.Select.TypeMember != "")
if (hook.Select.TypeMember != member) continue;
if (hook.Select.TypeAttributes != null && hook.Select.TypeAttributes.Length > 0)
{
object[] ats = type.GetCustomAttributes (true);
bool found = false;
foreach (object at in ats)
if (Array.IndexOf (hook.Select.TypeAttributes, at.GetType().FullName) != -1) { found = true; break; }
if (!found) continue;
}
}
foundHooks.Add (hook);
}
return foundHooks;
}
}
[XmlType ("hook")]
internal class Hook
{
[XmlAttribute ("type")]
public HookType HookType;
[XmlElement ("select")]
public Select Select;
[XmlElement ("insertBefore")]
public string InsertBefore;
[XmlElement ("insertAfter")]
public string InsertAfter;
[XmlElement ("replace")]
public string Replace;
public string GetCode (HookAction action)
{
if (action == HookAction.InsertBefore)
return InsertBefore;
else if (action == HookAction.InsertAfter)
return InsertAfter;
else
return Replace;
}
}
[XmlType ("select")]
internal class Select
{
[XmlElement ("typeName")]
public string TypeName;
[XmlElement("typeAttribute")]
public string[] TypeAttributes;
[XmlElement ("typeMember")]
public string TypeMember;
}
internal enum HookAction
{
InsertBefore,
InsertAfter,
Replace
}
[XmlType ("hookType")]
internal enum HookType
{
attributes,
elements,
unknownAttribute,
unknownElement,
member,
type
}
}

View File

@ -0,0 +1,190 @@
//
// System.Xml.Serialization.SerializationSource.cs
//
// Author:
// Lluis Sanchez Gual (lluis@ximian.com)
//
// Copyright (C) 2004 Novell, Inc.
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Collections;
using System.Globalization;
using System.Text;
namespace System.Xml.Serialization
{
internal abstract class SerializationSource
{
Type[] includedTypes;
string namspace;
bool canBeGenerated = true;
public SerializationSource (string namspace, Type[] includedTypes)
{
this.namspace = namspace;
this.includedTypes = includedTypes;
}
protected bool BaseEquals (SerializationSource other)
{
if (namspace != other.namspace) return false;
if (canBeGenerated != other.canBeGenerated) return false;
if (includedTypes == null)
return other.includedTypes == null;
if (other.includedTypes == null || includedTypes.Length != other.includedTypes.Length) return false;
for (int n=0; n<includedTypes.Length; n++)
if (!includedTypes[n].Equals (other.includedTypes[n])) return false;
return true;
}
public virtual bool CanBeGenerated
{
get { return canBeGenerated; }
set { canBeGenerated = value; }
}
}
internal class XmlTypeSerializationSource: SerializationSource
{
string attributeOverridesHash;
Type type;
string rootHash;
public XmlTypeSerializationSource (Type type, XmlRootAttribute root, XmlAttributeOverrides attributeOverrides, string namspace, Type[] includedTypes)
: base (namspace, includedTypes)
{
if (attributeOverrides != null) {
StringBuilder sb = new StringBuilder ();
attributeOverrides.AddKeyHash (sb);
attributeOverridesHash = sb.ToString ();
}
if (root != null) {
StringBuilder sb = new StringBuilder ();
root.AddKeyHash (sb);
rootHash = sb.ToString ();
}
this.type = type;
}
public override bool Equals (object o)
{
XmlTypeSerializationSource other = o as XmlTypeSerializationSource;
if (other == null) return false;
if (!type.Equals(other.type)) return false;
if (rootHash != other.rootHash) return false;
if (attributeOverridesHash != other.attributeOverridesHash) return false;
return base.BaseEquals (other);
}
public override int GetHashCode ()
{
return type.GetHashCode ();
}
}
internal class SoapTypeSerializationSource: SerializationSource
{
string attributeOverridesHash;
Type type;
public SoapTypeSerializationSource (Type type, SoapAttributeOverrides attributeOverrides, string namspace, Type[] includedTypes)
: base (namspace, includedTypes)
{
if (attributeOverrides != null) {
StringBuilder sb = new StringBuilder ();
attributeOverrides.AddKeyHash (sb);
attributeOverridesHash = sb.ToString ();
}
this.type = type;
}
public override bool Equals (object o)
{
SoapTypeSerializationSource other = o as SoapTypeSerializationSource;
if (other == null) return false;
if (!type.Equals(other.type)) return false;
if (attributeOverridesHash != other.attributeOverridesHash) return false;
return base.BaseEquals (other);
}
public override int GetHashCode ()
{
return type.GetHashCode ();
}
}
internal class MembersSerializationSource: SerializationSource
{
string elementName;
bool hasWrapperElement;
string membersHash;
// bool writeAccessors;
bool literalFormat;
public MembersSerializationSource (string elementName, bool hasWrapperElement, XmlReflectionMember [] members, bool writeAccessors,
bool literalFormat, string namspace, Type[] includedTypes)
: base (namspace, includedTypes)
{
this.elementName = elementName;
this.hasWrapperElement = hasWrapperElement;
// this.writeAccessors = writeAccessors;
this.literalFormat = literalFormat;
StringBuilder sb = new StringBuilder ();
sb.Append (members.Length.ToString(CultureInfo.InvariantCulture));
foreach (XmlReflectionMember mem in members)
mem.AddKeyHash (sb);
membersHash = sb.ToString();
}
public override bool Equals (object o)
{
MembersSerializationSource other = o as MembersSerializationSource;
if (other == null) return false;
if (literalFormat = other.literalFormat) return false;
if (elementName != other.elementName) return false;
if (hasWrapperElement != other.hasWrapperElement) return false;
if (membersHash != other.membersHash) return false;
return base.BaseEquals (other);
}
public override int GetHashCode ()
{
return membersHash.GetHashCode ();
}
}
}

View File

@ -0,0 +1,98 @@
//
// SoapAttributeAttribute.cs:
//
// Author:
// John Donagher (john@webmeta.com)
//
// (C) 2002 John Donagher
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Text;
namespace System.Xml.Serialization
{
/// <summary>
/// Summary description for SoapAttributeAttribute.
/// </summary>
[AttributeUsage(AttributeTargets.Property | AttributeTargets.Field
| AttributeTargets.Parameter | AttributeTargets.ReturnValue)]
public class SoapAttributeAttribute : Attribute
{
private string attrName;
private string dataType;
private string ns;
public SoapAttributeAttribute ()
{
}
public SoapAttributeAttribute (string attributeName)
{
this.attrName = attributeName;
}
public string AttributeName {
get {
if (attrName == null) {
return string.Empty;
}
return attrName;
}
set {
attrName = value;
}
}
public string DataType {
get {
if (dataType == null) {
return string.Empty;
}
return dataType;
}
set {
dataType = value;
}
}
public string Namespace {
get {
return ns;
}
set {
ns = value;
}
}
internal void AddKeyHash (System.Text.StringBuilder sb)
{
sb.Append ("SAA ");
KeyHelper.AddField (sb, 1, attrName);
KeyHelper.AddField (sb, 2, dataType);
KeyHelper.AddField (sb, 3, ns);
sb.Append ("|");
}
}
}

View File

@ -0,0 +1,104 @@
//
// SoapAttributeOverrides.cs:
//
// Author:
// John Donagher (john@webmeta.com)
//
// (C) 2002 John Donagher
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System;
using System.Collections;
namespace System.Xml.Serialization
{
/// <summary>
///
/// </summary>
public class SoapAttributeOverrides
{
/// <summary>
/// This class requires to store SoapAttrributes indexed by a key containg
/// both Type and Member Name. There are 3 approaches to this IMO.
/// 1. Make the key as "FullTypeName..MemberName", with ".." seperating Type and Member.
/// 2. Use a jagged 2D hashtable. The main hashtable is indexed by Type and each value
/// contains another hashtable which is indexed by member names. (Too many hashtables)
/// 3. Use a new class which emcompasses the Type and MemberName. An implementation is there
/// in TypeMember class in this namespace. (Too many instantiations of the class needed)
///
/// Method 1 is the most elegent, but I am not sure if the seperator is language insensitive.
/// What if someone writes a language which allows . in the member names.
/// </summary>
///
private Hashtable overrides;
public SoapAttributeOverrides ()
{
overrides = new Hashtable();
}
public SoapAttributes this [Type type]
{
get { return this [type, string.Empty]; }
}
public SoapAttributes this [Type type, string member]
{
get
{
return (SoapAttributes) overrides[GetKey(type,member)];
}
}
public void Add (Type type, SoapAttributes attributes)
{
Add(type, string.Empty, attributes);
}
public void Add (Type type, string member, SoapAttributes attributes)
{
if(overrides[GetKey(type, member)] != null)
throw new Exception("The attributes for the given type and Member already exist in the collection");
overrides.Add(GetKey(type,member), attributes);
}
private TypeMember GetKey(Type type, string member)
{
return new TypeMember(type, member);
}
internal void AddKeyHash (System.Text.StringBuilder sb)
{
sb.Append ("SAO ");
foreach (DictionaryEntry entry in overrides)
{
SoapAttributes val = (SoapAttributes) overrides [entry.Key];
sb.Append (entry.Key.ToString()).Append(' ');
val.AddKeyHash (sb);
}
sb.Append ("|");
}
}
}

View File

@ -0,0 +1,138 @@
//
// SoapAttributes.cs:
//
// Author:
// John Donagher (john@webmeta.com)
//
// (C) 2002 John Donagher
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.Reflection;
using System;
using System.ComponentModel;
namespace System.Xml.Serialization
{
/// <summary>
/// Summary description for SoapAttributes.
/// </summary>
public class SoapAttributes
{
private SoapAttributeAttribute soapAttribute;
private object soapDefaultValue = System.DBNull.Value;
private SoapElementAttribute soapElement;
private SoapEnumAttribute soapEnum;
private bool soapIgnore;
private SoapTypeAttribute soapType;
public SoapAttributes ()
{
}
public SoapAttributes (ICustomAttributeProvider provider)
{
object[] attributes = provider.GetCustomAttributes(false);
foreach(object obj in attributes)
{
if(obj is SoapAttributeAttribute)
soapAttribute = (SoapAttributeAttribute) obj;
else if(obj is DefaultValueAttribute)
soapDefaultValue = ((DefaultValueAttribute) obj).Value;
else if(obj is SoapElementAttribute)
soapElement = (SoapElementAttribute) obj;
else if(obj is SoapEnumAttribute)
soapEnum = (SoapEnumAttribute) obj;
else if(obj is SoapIgnoreAttribute)
soapIgnore = true;
else if(obj is SoapTypeAttribute)
soapType = (SoapTypeAttribute) obj;
}
}
public SoapAttributeAttribute SoapAttribute
{
get { return soapAttribute; }
set { soapAttribute = value; }
}
public object SoapDefaultValue
{
get { return soapDefaultValue; }
set { soapDefaultValue = value; }
}
public SoapElementAttribute SoapElement
{
get { return soapElement; }
set { soapElement = value; }
}
public SoapEnumAttribute SoapEnum
{
get { return soapEnum; }
set { soapEnum = value; }
}
public bool SoapIgnore
{
get { return soapIgnore; }
set { soapIgnore = value; }
}
public SoapTypeAttribute SoapType
{
get { return soapType; }
set { soapType = value; }
}
internal void AddKeyHash (System.Text.StringBuilder sb)
{
sb.Append ("SA ");
if (soapIgnore)
sb.Append ('i');
if (soapAttribute != null)
soapAttribute.AddKeyHash (sb);
if (soapElement != null)
soapElement.AddKeyHash (sb);
if (soapEnum != null)
soapEnum.AddKeyHash (sb);
if (soapType != null)
soapType.AddKeyHash (sb);
if (soapDefaultValue == null) {
sb.Append ("n");
}
else if (!(soapDefaultValue is System.DBNull)) {
string v = XmlCustomFormatter.ToXmlString (TypeTranslator.GetTypeData (soapDefaultValue.GetType()), soapDefaultValue);
sb.Append ("v" + v);
}
sb.Append ("|");
}
}
}

View File

@ -0,0 +1,208 @@
//
// System.Xml.Serialization.SoapCodeExporter
//
// Author:
// Tim Coleman (tim@timcoleman.com)
// Lluis Sanchez Gual (lluis@ximian.com)
//
// Copyright (C) Tim Coleman, 2002
//
//
// Permission is hereby granted, free of charge, to any person obtaining
// a copy of this software and associated documentation files (the
// "Software"), to deal in the Software without restriction, including
// without limitation the rights to use, copy, modify, merge, publish,
// distribute, sublicense, and/or sell copies of the Software, and to
// permit persons to whom the Software is furnished to do so, subject to
// the following conditions:
//
// The above copyright notice and this permission notice shall be
// included in all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
//
using System.CodeDom;
using System.CodeDom.Compiler;
using System.Collections;
namespace System.Xml.Serialization
{
public class SoapCodeExporter
#if NET_2_0
: CodeExporter
#endif
{
#region Fields
#if !NET_2_0
SoapMapCodeGenerator codeGenerator;
#endif
#endregion
#region Constructors
public SoapCodeExporter (CodeNamespace codeNamespace): this (codeNamespace, null)
{
}
public SoapCodeExporter (CodeNamespace codeNamespace, CodeCompileUnit codeCompileUnit)
{
codeGenerator = new SoapMapCodeGenerator (codeNamespace, codeCompileUnit);
}
#if NET_2_0
public SoapCodeExporter (CodeNamespace codeNamespace,
CodeCompileUnit codeCompileUnit,
CodeGenerationOptions options)
: this (codeNamespace, codeCompileUnit, null, options, null)
{
}
public SoapCodeExporter (CodeNamespace codeNamespace,
CodeCompileUnit codeCompileUnit,
CodeGenerationOptions options,
Hashtable mappings)
: this (codeNamespace, codeCompileUnit, null, options, mappings)
{
}
[MonoTODO]// FIXME: mappings?
public SoapCodeExporter (CodeNamespace codeNamespace,
CodeCompileUnit codeCompileUnit,
CodeDomProvider codeProvider,
CodeGenerationOptions options,
Hashtable mappings)
{
codeGenerator = new SoapMapCodeGenerator (codeNamespace, codeCompileUnit, codeProvider, options, mappings);
}
#endif
#endregion // Constructors
#region Properties
#if !NET_2_0
public CodeAttributeDeclarationCollection IncludeMetadata {
get { return codeGenerator.IncludeMetadata; }
}
#endif
#endregion // Properties
#region Methods
public void AddMappingMetadata (CodeAttributeDeclarationCollection metadata, XmlMemberMapping member)
{
AddMappingMetadata (metadata, member, false);
}
public void AddMappingMetadata (CodeAttributeDeclarationCollection metadata, XmlMemberMapping member, bool forceUseMemberName)
{
TypeData memType = member.TypeMapMember.TypeData;
CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Xml.Serialization.SoapElement");
if (forceUseMemberName || (member.ElementName != member.MemberName))
att.Arguments.Add (new CodeAttributeArgument (new CodePrimitiveExpression(member.ElementName)));
if (!TypeTranslator.IsDefaultPrimitiveTpeData (memType))
att.Arguments.Add (new CodeAttributeArgument ("DataType", new CodePrimitiveExpression(member.TypeName)));
if (att.Arguments.Count > 0)
metadata.Add (att);
}
public void ExportMembersMapping (XmlMembersMapping xmlMembersMapping)
{
codeGenerator.ExportMembersMapping (xmlMembersMapping);
}
public void ExportTypeMapping (XmlTypeMapping xmlTypeMapping)
{
codeGenerator.ExportTypeMapping (xmlTypeMapping, true);
}
#endregion // Methods
}
class SoapMapCodeGenerator : MapCodeGenerator
{
public SoapMapCodeGenerator (CodeNamespace codeNamespace, CodeCompileUnit codeCompileUnit)
: base (codeNamespace, codeCompileUnit, CodeGenerationOptions.None)
{
includeArrayTypes = true;
}
public SoapMapCodeGenerator (CodeNamespace codeNamespace, CodeCompileUnit codeCompileUnit, CodeDomProvider codeProvider, CodeGenerationOptions options, Hashtable mappings)
: base (codeNamespace, codeCompileUnit, codeProvider, options, mappings)
{
}
protected override void GenerateClass (XmlTypeMapping map, CodeTypeDeclaration codeClass, bool isTopLevel)
{
CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Xml.Serialization.SoapType");
if (map.XmlType != map.TypeData.TypeName) att.Arguments.Add (GetArg (map.XmlType));
if (map.XmlTypeNamespace != "") att.Arguments.Add (GetArg ("Namespace", map.XmlTypeNamespace));
AddCustomAttribute (codeClass, att, false);
}
protected override void GenerateClassInclude (CodeAttributeDeclarationCollection attributes, XmlTypeMapping map)
{
CodeAttributeDeclaration iatt = new CodeAttributeDeclaration ("System.Xml.Serialization.SoapInclude");
iatt.Arguments.Add (new CodeAttributeArgument (new CodeTypeOfExpression(map.TypeData.FullTypeName)));
attributes.Add (iatt);
}
protected override void GenerateAttributeMember (CodeAttributeDeclarationCollection attributes, XmlTypeMapMemberAttribute attinfo, string defaultNamespace, bool forceUseMemberName)
{
CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Xml.Serialization.SoapAttribute");
if (attinfo.Name != attinfo.AttributeName) att.Arguments.Add (GetArg (attinfo.AttributeName));
if (attinfo.Namespace != defaultNamespace) att.Arguments.Add (GetArg ("Namespace", attinfo.Namespace));
if (!TypeTranslator.IsDefaultPrimitiveTpeData(attinfo.TypeData)) att.Arguments.Add (GetArg ("DataType",attinfo.TypeData.XmlType));
attributes.Add (att);
}
protected override void GenerateElementInfoMember (CodeAttributeDeclarationCollection attributes, XmlTypeMapMemberElement member, XmlTypeMapElementInfo einfo, TypeData defaultType, string defaultNamespace, bool addAlwaysAttr, bool forceUseMemberName)
{
CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Xml.Serialization.SoapElement");
if (forceUseMemberName || einfo.ElementName != member.Name) att.Arguments.Add (GetArg (einfo.ElementName));
// if (einfo.IsNullable) att.Arguments.Add (GetArg ("IsNullable", true)); MS seems to ignore this
if (!TypeTranslator.IsDefaultPrimitiveTpeData(einfo.TypeData)) att.Arguments.Add (GetArg ("DataType",einfo.TypeData.XmlType));
if (addAlwaysAttr || att.Arguments.Count > 0) attributes.Add (att);
}
protected override void GenerateEnum (XmlTypeMapping map, CodeTypeDeclaration codeEnum, bool isTopLevel)
{
CodeAttributeDeclaration att = new CodeAttributeDeclaration ("System.Xml.Serialization.SoapType");
if (map.XmlType != map.TypeData.TypeName) att.Arguments.Add (GetArg (map.XmlType));
if (map.XmlTypeNamespace != "") att.Arguments.Add (GetArg ("Namespace", map.XmlTypeNamespace));
AddCustomAttribute (codeEnum, att, false);
}
protected override void GenerateEnumItem (CodeMemberField codeField, EnumMap.EnumMapMember emem)
{
if (emem.EnumName != emem.XmlName)
{
CodeAttributeDeclaration xatt = new CodeAttributeDeclaration ("System.Xml.Serialization.SoapEnum");
xatt.Arguments.Add (GetArg ("Name", emem.XmlName));
AddCustomAttribute (codeField, xatt, true);
}
}
protected override void GenerateSpecifierMember (CodeTypeMember codeField)
{
AddCustomAttribute (codeField, "System.Xml.Serialization.SoapIgnore");
}
}
}

Some files were not shown because too many files have changed in this diff Show More