From: Daniel C. \(kzu\) <dca...@us...> - 2005-10-31 11:49:34
|
Update of /cvsroot/mvp-xml/Design/v2/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24252/v2/tests Modified Files: CustomerSchema.Serialization.cs Mvp.Xml.Design.Tests.csproj Log Message: Fixed replacement of code. Index: CustomerSchema.Serialization.cs =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/tests/CustomerSchema.Serialization.cs,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- CustomerSchema.Serialization.cs 31 Oct 2005 09:31:24 -0000 1.1 +++ CustomerSchema.Serialization.cs 31 Oct 2005 11:49:18 -0000 1.2 @@ -1 +1,405 @@ -// Containing project \ No newline at end of file +//------------------------------------------------------------------------------ +// <autogenerated> +// This code was generated by the Mvp.Xml.XGen tool. +// Tool Version: 1.1.1.0 +// Runtime Version: 2.0.50727.42 +// +// Changes to this file may cause incorrect behavior and will be lost if +// the code is regenerated. +// </autogenerated> +//------------------------------------------------------------------------------ + +#pragma warning disable 0642, 0219 +namespace CustomerSchemaSerialization +{ + using System.Xml.Serialization; + using System; + + + /// /// <summary>Custom reader for CustomerSchema instances.</summary> + internal class CustomerSchemaReader : CustomerSchemaSerializer.BaseReader + { + + + /// <remarks/> + protected override global::Mvp.Xml.Design.Tests.CustomerSchema Read3_CustomerSchema(bool isNullable, bool checkType) + { + global::Mvp.Xml.Design.Tests.CustomerSchema obj = base.Read3_CustomerSchema(isNullable, checkType); + CustomerSchemaDeserializedHandler handler = CustomerSchemaDeserialized; + if (handler != null) + handler(obj); + + return obj; + } + + /// <remarks/> + protected override global::Mvp.Xml.Design.Tests.CustomerSchemaOrders Read2_CustomerSchemaOrders(bool isNullable, bool checkType) + { + global::Mvp.Xml.Design.Tests.CustomerSchemaOrders obj = base.Read2_CustomerSchemaOrders(isNullable, checkType); + CustomerSchemaOrdersDeserializedHandler handler = CustomerSchemaOrdersDeserialized; + if (handler != null) + handler(obj); + + return obj; + } + + /// <summary>Reads an object of type Mvp.Xml.Design.Tests.CustomerSchema.</summary> + internal Mvp.Xml.Design.Tests.CustomerSchema Read() + { + return (Mvp.Xml.Design.Tests.CustomerSchema) Read4_CustomerSchema(); + } + + /// /// <remarks/> + public event CustomerSchemaDeserializedHandler CustomerSchemaDeserialized; + + /// /// <remarks/> + public event CustomerSchemaOrdersDeserializedHandler CustomerSchemaOrdersDeserialized; + } + + /// /// <remarks/> + public delegate void CustomerSchemaDeserializedHandler(global::Mvp.Xml.Design.Tests.CustomerSchema customerSchema); + + /// /// <remarks/> + public delegate void CustomerSchemaOrdersDeserializedHandler(global::Mvp.Xml.Design.Tests.CustomerSchemaOrders customerSchemaOrders); + + /// /// <summary>Custom writer for CustomerSchema instances.</summary> + internal class CustomerSchemaWriter : CustomerSchemaSerializer.BaseWriter + { + + + /// <summary>Writes an object of type Mvp.Xml.Design.Tests.CustomerSchema.</summary> + internal void Write(Mvp.Xml.Design.Tests.CustomerSchema value) + { + Write4_CustomerSchema(value); + } + } +} +#if _DYNAMIC_XMLSERIALIZER_COMPILATION +[assembly:System.Security.AllowPartiallyTrustedCallers()] +[assembly:System.Security.SecurityTransparent()] +#endif + +namespace CustomerSchemaSerialization { + + internal partial class CustomerSchemaSerializer { + internal class BaseWriter : System.Xml.Serialization.XmlSerializationWriter { + + protected internal void Write4_CustomerSchema(object o) { + WriteStartDocument(); + if (o == null) { + WriteEmptyTag(@"CustomerSchema", @"http://tempuri.org/CustomerSchema.xsd"); + return; + } + TopLevelElement(); + Write3_CustomerSchema(@"CustomerSchema", @"http://tempuri.org/CustomerSchema.xsd", ((global::Mvp.Xml.Design.Tests.CustomerSchema)o), false, false); + } + + void Write3_CustomerSchema(string n, string ns, global::Mvp.Xml.Design.Tests.CustomerSchema o, bool isNullable, bool needType) { + if ((object)o == null) { + if (isNullable) WriteNullTagLiteral(n, ns); + return; + } + if (!needType) { + System.Type t = o.GetType(); + if (t == typeof(global::Mvp.Xml.Design.Tests.CustomerSchema)) { + } + else { + throw CreateUnknownTypeException(o); + } + } + WriteStartElement(n, ns, o, false, null); + if (needType) WriteXsiType(null, @"http://tempuri.org/CustomerSchema.xsd"); + WriteElementString(@"Name", @"http://tempuri.org/CustomerSchema.xsd", ((global::System.String)o.@Name)); + Write2_CustomerSchemaOrders(@"Orders", @"http://tempuri.org/CustomerSchema.xsd", ((global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)o.@Orders), false, false); + WriteEndElement(o); + } + + void Write2_CustomerSchemaOrders(string n, string ns, global::Mvp.Xml.Design.Tests.CustomerSchemaOrders o, bool isNullable, bool needType) { + if ((object)o == null) { + if (isNullable) WriteNullTagLiteral(n, ns); + return; + } + if (!needType) { + System.Type t = o.GetType(); + if (t == typeof(global::Mvp.Xml.Design.Tests.CustomerSchemaOrders)) { + } + else { + throw CreateUnknownTypeException(o); + } + } + WriteStartElement(n, ns, o, false, null); + if (needType) WriteXsiType(null, @"http://tempuri.org/CustomerSchema.xsd"); + WriteElementStringRaw(@"Date", @"http://tempuri.org/CustomerSchema.xsd", FromDateTime(((global::System.DateTime)o.@Date))); + WriteEndElement(o); + } + + protected override void InitCallbacks() { + } + } + } + + internal partial class CustomerSchemaSerializer { + internal class BaseReader : System.Xml.Serialization.XmlSerializationReader { + + protected internal object Read4_CustomerSchema() { + object o = null; + Reader.MoveToContent(); + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (((object) Reader.LocalName == (object)id1_CustomerSchema && (object) Reader.NamespaceURI == (object)id2_Item)) { + o = Read3_CustomerSchema(false, true); + } + else { + throw CreateUnknownNodeException(); + } + } + else { + UnknownNode(null, @"http://tempuri.org/CustomerSchema.xsd:CustomerSchema"); + } + return (object)o; + } + + /// <remarks/> + protected virtual global::Mvp.Xml.Design.Tests.CustomerSchema Read3_CustomerSchema(bool isNullable, bool checkType) { + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + bool isNull = false; + if (isNullable) isNull = ReadNull(); + if (checkType) { + if (xsiType == null || ((object) ((System.Xml.XmlQualifiedName)xsiType).Name == (object)id3_Item && (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) { + } + else + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); + } + if (isNull) return null; + global::Mvp.Xml.Design.Tests.CustomerSchema o; + o = new global::Mvp.Xml.Design.Tests.CustomerSchema(); + bool[] paramsRead = new bool[2]; + while (Reader.MoveToNextAttribute()) { + if (!IsXmlnsAttribute(Reader.Name)) { + UnknownNode((object)o); + } + } + Reader.MoveToElement(); + if (Reader.IsEmptyElement) { + Reader.Skip(); + return o; + } + Reader.ReadStartElement(); + Reader.MoveToContent(); + int whileIterations0 = 0; + int readerCount0 = ReaderCount; + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (!paramsRead[0] && ((object) Reader.LocalName == (object)id4_Name && (object) Reader.NamespaceURI == (object)id2_Item)) { + { + o.@Name = Reader.ReadElementString(); + } + paramsRead[0] = true; + } + else if (!paramsRead[1] && ((object) Reader.LocalName == (object)id5_Orders && (object) Reader.NamespaceURI == (object)id2_Item)) { + o.@Orders = Read2_CustomerSchemaOrders(false, true); + paramsRead[1] = true; + } + else { + UnknownNode((object)o, @"http://tempuri.org/CustomerSchema.xsd:Name, http://tempuri.org/CustomerSchema.xsd:Orders"); + } + } + else { + UnknownNode((object)o, @"http://tempuri.org/CustomerSchema.xsd:Name, http://tempuri.org/CustomerSchema.xsd:Orders"); + } + Reader.MoveToContent(); + CheckReaderCount(ref whileIterations0, ref readerCount0); + } + ReadEndElement(); + return o; + } + + /// <remarks/> + protected virtual global::Mvp.Xml.Design.Tests.CustomerSchemaOrders Read2_CustomerSchemaOrders(bool isNullable, bool checkType) { + System.Xml.XmlQualifiedName xsiType = checkType ? GetXsiType() : null; + bool isNull = false; + if (isNullable) isNull = ReadNull(); + if (checkType) { + if (xsiType == null || ((object) ((System.Xml.XmlQualifiedName)xsiType).Name == (object)id3_Item && (object) ((System.Xml.XmlQualifiedName)xsiType).Namespace == (object)id2_Item)) { + } + else + throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)xsiType); + } + if (isNull) return null; + global::Mvp.Xml.Design.Tests.CustomerSchemaOrders o; + o = new global::Mvp.Xml.Design.Tests.CustomerSchemaOrders(); + bool[] paramsRead = new bool[1]; + while (Reader.MoveToNextAttribute()) { + if (!IsXmlnsAttribute(Reader.Name)) { + UnknownNode((object)o); + } + } + Reader.MoveToElement(); + if (Reader.IsEmptyElement) { + Reader.Skip(); + return o; + } + Reader.ReadStartElement(); + Reader.MoveToContent(); + int whileIterations1 = 0; + int readerCount1 = ReaderCount; + while (Reader.NodeType != System.Xml.XmlNodeType.EndElement && Reader.NodeType != System.Xml.XmlNodeType.None) { + if (Reader.NodeType == System.Xml.XmlNodeType.Element) { + if (!paramsRead[0] && ((object) Reader.LocalName == (object)id6_Date && (object) Reader.NamespaceURI == (object)id2_Item)) { + { + o.@Date = ToDateTime(Reader.ReadElementString()); + } + paramsRead[0] = true; + } + else { + UnknownNode((object)o, @"http://tempuri.org/CustomerSchema.xsd:Date"); + } + } + else { + UnknownNode((object)o, @"http://tempuri.org/CustomerSchema.xsd:Date"); + } + Reader.MoveToContent(); + CheckReaderCount(ref whileIterations1, ref readerCount1); + } + ReadEndElement(); + return o; + } + + protected override void InitCallbacks() { + } + + string id1_CustomerSchema; + string id4_Name; + string id2_Item; + string id6_Date; + string id3_Item; + string id5_Orders; + + protected override void InitIDs() { + id1_CustomerSchema = Reader.NameTable.Add(@"CustomerSchema"); + id4_Name = Reader.NameTable.Add(@"Name"); + id2_Item = Reader.NameTable.Add(@"http://tempuri.org/CustomerSchema.xsd"); + id6_Date = Reader.NameTable.Add(@"Date"); + id3_Item = Reader.NameTable.Add(@""); + id5_Orders = Reader.NameTable.Add(@"Orders"); + } + } + } + + internal abstract class CustomerSchemaSerializerBase : System.Xml.Serialization.XmlSerializer { + protected override System.Xml.Serialization.XmlSerializationReader CreateReader() { + return new CustomerSchemaSerializer.BaseReader(); + } + protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter() { + return new CustomerSchemaSerializer.BaseWriter(); + } + } + + internal sealed partial class CustomerSchemaSerializer : CustomerSchemaSerializerBase { + + CustomerSchemaReader _reader; + CustomerSchemaWriter _writer; + + /// <summary>Constructs the serializer.</summary> + public CustomerSchemaSerializer() + { + } + + /// <summary>Constructs the serializer with a pre-built reader.</summary> + public CustomerSchemaSerializer(CustomerSchemaReader reader) + { + _reader = reader; + } + + /// <summary>Constructs the serializer with a pre-built writer.</summary> + public CustomerSchemaSerializer(CustomerSchemaWriter writer) + { + _writer = writer; + } + + /// <summary>Constructs the serializer with pre-built reader and writer.</summary> + public CustomerSchemaSerializer(CustomerSchemaReader reader, CustomerSchemaWriter writer) + { + _reader = reader; + _writer = writer; + } + + /// <remarks/> + protected override System.Xml.Serialization.XmlSerializationReader CreateReader() + { + if (_reader != null) return _reader; + + return base.CreateReader(); + } + + /// <remarks/> + protected override System.Xml.Serialization.XmlSerializationWriter CreateWriter() + { + if (_writer != null) return _writer; + + return base.CreateWriter(); + } + + public override System.Boolean CanDeserialize(System.Xml.XmlReader xmlReader) { + return xmlReader.IsStartElement(@"CustomerSchema", @"http://tempuri.org/CustomerSchema.xsd"); + } + + protected override void Serialize(object objectToSerialize, System.Xml.Serialization.XmlSerializationWriter writer) { + ((BaseWriter)writer).Write4_CustomerSchema(objectToSerialize); + } + + protected override object Deserialize(System.Xml.Serialization.XmlSerializationReader reader) { + return ((BaseReader)reader).Read4_CustomerSchema(); + } + } + + internal partial class CustomerSchemaSerializer { + internal class XmlSerializerContract : global::System.Xml.Serialization.XmlSerializerImplementation { + public override global::System.Xml.Serialization.XmlSerializationReader Reader { get { return new CustomerSchemaSerializer.BaseReader(); } } + public override global::System.Xml.Serialization.XmlSerializationWriter Writer { get { return new CustomerSchemaSerializer.BaseWriter(); } } + System.Collections.Hashtable readMethods = null; + public override System.Collections.Hashtable ReadMethods { + get { + if (readMethods == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp[@"Mvp.Xml.Design.Tests.CustomerSchema:http://tempuri.org/CustomerSchema.xsd::False:"] = @"Read4_CustomerSchema"; + if (readMethods == null) readMethods = _tmp; + } + return readMethods; + } + } + System.Collections.Hashtable writeMethods = null; + public override System.Collections.Hashtable WriteMethods { + get { + if (writeMethods == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp[@"Mvp.Xml.Design.Tests.CustomerSchema:http://tempuri.org/CustomerSchema.xsd::False:"] = @"Write4_CustomerSchema"; + if (writeMethods == null) writeMethods = _tmp; + } + return writeMethods; + } + } + System.Collections.Hashtable typedSerializers = null; + public override System.Collections.Hashtable TypedSerializers { + get { + if (typedSerializers == null) { + System.Collections.Hashtable _tmp = new System.Collections.Hashtable(); + _tmp.Add(@"Mvp.Xml.Design.Tests.CustomerSchema:http://tempuri.org/CustomerSchema.xsd::False:", new CustomerSchemaSerializer()); + if (typedSerializers == null) typedSerializers = _tmp; + } + return typedSerializers; + } + } + public override System.Boolean CanSerialize(System.Type type) { + if (type == typeof(global::Mvp.Xml.Design.Tests.CustomerSchema)) return true; + return false; + } + public override System.Xml.Serialization.XmlSerializer GetSerializer(System.Type type) { + if (type == typeof(global::Mvp.Xml.Design.Tests.CustomerSchema)) return new CustomerSchemaSerializer(); + return null; + } + } + } +} + + +#pragma warning restore 0642, 0219 Index: Mvp.Xml.Design.Tests.csproj =================================================================== RCS file: /cvsroot/mvp-xml/Design/v2/tests/Mvp.Xml.Design.Tests.csproj,v retrieving revision 1.1 retrieving revision 1.2 diff -u -d -r1.1 -r1.2 --- Mvp.Xml.Design.Tests.csproj 31 Oct 2005 09:31:24 -0000 1.1 +++ Mvp.Xml.Design.Tests.csproj 31 Oct 2005 11:49:18 -0000 1.2 @@ -123,7 +123,7 @@ </PropertyGroup> <ProjectExtensions> <VisualStudio> - <UserProperties Mvp__Xml__Design__Tests___Customer__cs="Mvp.Xml.Design.Tests.Customer;Mvp.Xml.Design.Tests" Mvp__Xml__Design__Tests___CustomerSchema__xsd___CustomerSchema__cs="Mvp.Xml.Design.Tests.CustomerSchema;CustomerSchemaSerialization" /> + <UserProperties Mvp__Xml__Design__Tests___CustomerSchema__xsd___CustomerSchema__cs="Mvp.Xml.Design.Tests.CustomerSchema;CustomerSchemaSerialization" Mvp__Xml__Design__Tests___Customer__cs="Mvp.Xml.Design.Tests.Customer;Mvp.Xml.Design.Tests" /> </VisualStudio> </ProjectExtensions> </Project> \ No newline at end of file |