mirror of
https://github.com/BepInEx/mono.git
synced 2026-11-18 03:51:19 -10:00
* XmlSerializationReader.cs: implemented a few methods. * XmlAnyElementAttribute.cs: * XmlArrayAttribute.cs: * XmlChoiceIdentifierAttribute.cs: * XmlElementAttribute.cs: * XmlMemberMapping.cs: * XmlMembersMapping.cs: class status based fixes. svn path=/trunk/mcs/; revision=7578
530 lines
12 KiB
C#
530 lines
12 KiB
C#
//
|
|
// System.Xml.Serialization.XmlSerializationReader.cs
|
|
//
|
|
// Authors:
|
|
// Tim Coleman ([email protected])
|
|
// Gonzalo Paniagua Javier ([email protected])
|
|
//
|
|
// Copyright (C) Tim Coleman, 2002
|
|
// (c) 2002 Ximian, Inc. (http://www.ximian.com)
|
|
//
|
|
|
|
using System;
|
|
using System.Collections;
|
|
using System.Xml;
|
|
|
|
namespace System.Xml.Serialization {
|
|
public abstract class XmlSerializationReader {
|
|
|
|
#region Fields
|
|
|
|
XmlDocument document;
|
|
XmlReader reader;
|
|
ArrayList fixups;
|
|
ArrayList collFixups;
|
|
Hashtable readCallbacks = new Hashtable ();
|
|
Hashtable typesCallbacks = new Hashtable ();
|
|
|
|
string w3SchemaNS;
|
|
string w3SchemaNS2000;
|
|
string w3SchemaNS1999;
|
|
string w3InstanceNS;
|
|
string w3InstanceNS2000;
|
|
string w3InstanceNS1999;
|
|
string soapNS;
|
|
string schema;
|
|
string wsdlNS;
|
|
string wsdlArrayType;
|
|
string nullX;
|
|
string nil;
|
|
string typeX;
|
|
string arrayType;
|
|
string anyType;
|
|
#endregion
|
|
|
|
private void Initialize ()
|
|
{
|
|
w3SchemaNS = reader.NameTable.Add ("http://www.w3.org/2001/XMLSchema");
|
|
w3SchemaNS2000 = reader.NameTable.Add ("http://www.w3.org/2000/10/XMLSchema");
|
|
w3SchemaNS1999 = reader.NameTable.Add ("http://www.w3.org/1999/XMLSchema");
|
|
w3InstanceNS = reader.NameTable.Add ("http://www.w3.org/2001/XMLSchema-instance");
|
|
w3InstanceNS2000 = reader.NameTable.Add ("http://www.w3.org/2000/10/XMLSchema-instance");
|
|
w3InstanceNS1999 = reader.NameTable.Add ("http://www.w3.org/1999/XMLSchema-instance");
|
|
soapNS = reader.NameTable.Add ("http://schemas.xmlsoap.org/soap/encoding/");
|
|
schema = reader.NameTable.Add ("schema");
|
|
wsdlNS = reader.NameTable.Add ("http://schemas.xmlsoap.org/wsdl/");
|
|
wsdlArrayType = reader.NameTable.Add ("arrayType");
|
|
nullX = reader.NameTable.Add ("null");
|
|
nil = reader.NameTable.Add ("nil");
|
|
typeX = reader.NameTable.Add ("type");
|
|
arrayType = reader.NameTable.Add ("arrayType");
|
|
anyType = reader.NameTable.Add ("anyType");
|
|
InitIDs ();
|
|
}
|
|
|
|
protected XmlSerializationReader ()
|
|
{
|
|
}
|
|
|
|
protected XmlDocument Document
|
|
{
|
|
get {
|
|
if (document == null)
|
|
document = new XmlDocument (reader.NameTable);
|
|
|
|
return document;
|
|
}
|
|
}
|
|
|
|
protected XmlReader Reader {
|
|
get { return reader; }
|
|
}
|
|
|
|
#region Methods
|
|
|
|
protected void AddFixup (CollectionFixup fixup)
|
|
{
|
|
if (collFixups == null)
|
|
collFixups = new ArrayList();
|
|
collFixups.Add(fixup);
|
|
}
|
|
|
|
protected void AddFixup (Fixup fixup)
|
|
{
|
|
if (fixups == null)
|
|
fixups = new ArrayList();
|
|
fixups.Add(fixup);
|
|
}
|
|
|
|
protected void AddReadCallback (string name, string ns, Type type, XmlSerializationReadCallback read)
|
|
{
|
|
XmlNameTable nt = reader.NameTable;
|
|
XmlQualifiedName xqn = new XmlQualifiedName (nt.Add (name), nt.Add (ns));
|
|
readCallbacks.Add (xqn, read);
|
|
typesCallbacks.Add (xqn, type);
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected void AddTarget (string id, object o)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected Exception CreateAbstractTypeException (string name, string ns)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
protected Exception CreateInvalidCastException (Type type, object value)
|
|
{
|
|
string message = String.Format ("Cannot assign object of type {0} to an object of type {1}.", value.GetType (), type);
|
|
return new InvalidCastException (message);
|
|
}
|
|
|
|
protected Exception CreateReadOnlyCollectionException (string name)
|
|
{
|
|
string message = String.Format ("Could not serialize {0}. Default constructors are required for collections and enumerators.", name);
|
|
return new InvalidOperationException (message);
|
|
}
|
|
|
|
protected Exception CreateUnknownConstantException (string value, Type enumType)
|
|
{
|
|
string message = String.Format ("'{0}' is not a valid value for {1}.", value, enumType);
|
|
return new InvalidOperationException (message);
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected Exception CreateUnknownNodeException ()
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected Exception CreateUnknownTypeException (XmlQualifiedName type)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
protected Array EnsureArrayIndex (Array a, int index, Type elementType)
|
|
{
|
|
if (a != null && index < a.Length)
|
|
return a;
|
|
|
|
int size;
|
|
if (a == null) {
|
|
size = 32;
|
|
} else {
|
|
size = a.Length * 2;
|
|
}
|
|
|
|
Array result = Array.CreateInstance (elementType, size);
|
|
if (a != null)
|
|
Array.Copy (a, result, index);
|
|
|
|
return result;
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected void FixupArrayRefs (object fixup)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected int GetArrayLength (string name, string ns)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
protected bool GetNullAttr ()
|
|
{
|
|
string na = reader.GetAttribute (nullX, w3InstanceNS);
|
|
if (na == null) {
|
|
na = reader.GetAttribute (nil, w3InstanceNS);
|
|
if (na == null) {
|
|
na = reader.GetAttribute (nullX, w3InstanceNS2000);
|
|
if (na == null)
|
|
na = reader.GetAttribute (nullX, w3InstanceNS1999);
|
|
}
|
|
}
|
|
return (na != null);
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected object GetTarget (string id)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected XmlQualifiedName GetXsiType ()
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
protected abstract void InitCallbacks ();
|
|
protected abstract void InitIDs ();
|
|
|
|
protected bool IsXmlnsAttribute (string name)
|
|
{
|
|
int length = name.Length;
|
|
if (length < 5)
|
|
return false;
|
|
|
|
if (length == 5)
|
|
return (name == "xmlns");
|
|
|
|
return name.StartsWith ("xmlns:");
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected void ParseWsdlArrayType (XmlAttribute attr)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected XmlQualifiedName ReadElementQualifiedName ()
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
protected void ReadEndElement ()
|
|
{
|
|
while (reader.NodeType == XmlNodeType.Whitespace)
|
|
reader.Skip ();
|
|
|
|
if (reader.NodeType != XmlNodeType.None) {
|
|
reader.ReadEndElement ();
|
|
} else {
|
|
reader.Skip ();
|
|
}
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected bool ReadNull ()
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected XmlQualifiedName ReadNullableQualifiedName ()
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected string ReadNullableString ()
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected bool ReadReference (out string fixupReference)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected object ReadReferencedElement ()
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected object ReadReferencedElement (string name, string ns)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected void ReadReferencedElements ()
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected object ReadReferencingElement (out string fixupReference)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected object ReadReferencingElement (string name, string ns, out string fixupReference)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected object ReadReferencingElement (string name, string ns, bool elementCanBeType, out string fixupReference)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected IXmlSerializable ReadSerializable (IXmlSerializable serializable)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
protected string ReadString (string value)
|
|
{
|
|
if (value == null || value == String.Empty)
|
|
return reader.ReadString ();
|
|
|
|
return (value + reader.ReadString ());
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected object ReadTypedPrimitive (XmlQualifiedName type)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected XmlNode ReadXmlNode (bool wrapped)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected void Referenced (object o)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected Array ShrinkArray (Array a, int length, Type elementType, bool isNullable)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected byte[] ToByteArrayBase64 (bool isNull)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected static byte[] ToByteArrayBase64 (string value)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected byte[] ToByteArrayHex (bool isNull)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected static byte[] ToByteArrayHex (string value)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
protected static char ToChar (string value)
|
|
{
|
|
return XmlCustomFormatter.ToChar (value);
|
|
}
|
|
|
|
protected static DateTime ToDate (string value)
|
|
{
|
|
return XmlCustomFormatter.ToDate (value);
|
|
}
|
|
|
|
protected static DateTime ToDateTime (string value)
|
|
{
|
|
return XmlCustomFormatter.ToDateTime (value);
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected static long ToEnum (string value, Hashtable h, string typeName)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
protected static DateTime ToTime (string value)
|
|
{
|
|
return XmlCustomFormatter.ToTime (value);
|
|
}
|
|
|
|
protected static string ToXmlName (string value)
|
|
{
|
|
return XmlCustomFormatter.ToXmlName (value);
|
|
}
|
|
|
|
protected static string ToXmlNCName (string value)
|
|
{
|
|
return XmlCustomFormatter.ToXmlNCName (value);
|
|
}
|
|
|
|
protected static string ToXmlNmToken (string value)
|
|
{
|
|
return XmlCustomFormatter.ToXmlNmToken (value);
|
|
}
|
|
|
|
protected static string ToXmlNmTokens (string value)
|
|
{
|
|
return XmlCustomFormatter.ToXmlNmTokens (value);
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected XmlQualifiedName ToXmlQualifiedName (string value)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected void UnknownAttribute (object o, XmlAttribute attr)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected void UnknownElement (object o, XmlElement elem)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected void UnknownNode (object o)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
[MonoTODO ("Implement")]
|
|
protected void UnreferencedObject (string id, object o)
|
|
{
|
|
throw new NotImplementedException ();
|
|
}
|
|
|
|
#endregion // Methods
|
|
|
|
protected class CollectionFixup {
|
|
|
|
#region Fields
|
|
|
|
XmlSerializationCollectionFixupCallback callback;
|
|
object collection;
|
|
object collectionItems;
|
|
|
|
#endregion // Fields
|
|
|
|
#region Constructors
|
|
|
|
[MonoTODO]
|
|
public CollectionFixup (object collection, XmlSerializationCollectionFixupCallback callback, object collectionItems)
|
|
{
|
|
this.callback = callback;
|
|
this.collection = collection;
|
|
this.collectionItems = collectionItems;
|
|
}
|
|
|
|
#endregion // Constructors
|
|
|
|
#region Properties
|
|
|
|
public XmlSerializationCollectionFixupCallback Callback {
|
|
get { return callback; }
|
|
}
|
|
|
|
public object Collection {
|
|
get { return collection; }
|
|
}
|
|
|
|
public object CollectionItems {
|
|
get { return collectionItems; }
|
|
}
|
|
|
|
#endregion // Properties
|
|
}
|
|
|
|
protected class Fixup {
|
|
|
|
#region Fields
|
|
|
|
object source;
|
|
string[] ids;
|
|
XmlSerializationFixupCallback callback;
|
|
|
|
#endregion // Fields
|
|
|
|
#region Constructors
|
|
|
|
[MonoTODO]
|
|
public Fixup (object o, XmlSerializationFixupCallback callback, int count)
|
|
{
|
|
this.callback = callback;
|
|
}
|
|
|
|
[MonoTODO]
|
|
public Fixup (object o, XmlSerializationFixupCallback callback, string[] ids)
|
|
{
|
|
this.callback = callback;
|
|
}
|
|
|
|
#endregion // Constructors
|
|
|
|
#region Properties
|
|
|
|
public XmlSerializationFixupCallback Callback {
|
|
get { return callback; }
|
|
}
|
|
|
|
public string[] Ids {
|
|
get { return ids; }
|
|
}
|
|
|
|
public object Source {
|
|
get { return source; }
|
|
set { source = value; }
|
|
}
|
|
|
|
#endregion // Properties
|
|
}
|
|
}
|
|
}
|
|
|