From: Daniel C. \(kzu\) <dca...@us...> - 2004-10-21 21:04:09
|
Update of /cvsroot/mvp-xml/Design/v1/tests In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv615/v1/tests Added Files: AssemblyInfo.cs Customer.cs Customer.Serialization.cs Design.Tests.csproj Design.Tests.sln TestSerialization.cs Log Message: --- NEW FILE: Customer.Serialization.cs --- namespace Mvp.Xml.Design.Tests { using System.Xml.Serialization; using System; /// <summary>Custom serializer for Customer type.</summary public class CustomerSerializer : System.Xml.Serialization.XmlSerializer { CustomerReader _reader; CustomerWriter _writer; /// <summary>Constructs the serializer with default reader and writer instances.</summary> public CustomerSerializer() { } /// <summary>Constructs the serializer with a pre-built reader.</summary> public CustomerSerializer(CustomerReader reader) { _reader = reader; } /// <summary>Constructs the serializer with a pre-built writer.</summary> public CustomerSerializer(CustomerWriter writer) { _writer = writer; } /// <summary>Constructs the serializer with pre-built reader and writer.</summary> public CustomerSerializer(CustomerReader reader, CustomerWriter writer) { _reader = reader; _writer = writer; } /// <summary>See <see cref="XmlSerializer.CreateReader"/>.</summary> protected override XmlSerializationReader CreateReader() { if (_reader != null) return _reader; else return new CustomerReader(); } /// <summary>See <see cref="XmlSerializer.CreateWriter"/>.</summary> protected override XmlSerializationWriter CreateWriter() { if (_writer != null) return _writer; else return new CustomerWriter(); } /// <summary>See <see cref="XmlSerializer.Deserialize"/>.</summary> protected override object Deserialize(XmlSerializationReader reader) { if (!(reader is CustomerReader)) throw new ArgumentException("reader"); return ((CustomerReader)reader).Read(); } /// <summary>See <see cref="XmlSerializer.Serialize"/>.</summary> protected override void Serialize(object o, XmlSerializationWriter writer) { if (!(writer is CustomerWriter)) throw new ArgumentException("writer"); ((CustomerWriter)writer).Write((Mvp.Xml.Design.Tests.Customer)o); } public class Reader : System.Xml.Serialization.XmlSerializationReader { /// <remarks/> protected virtual Mvp.Xml.Design.Tests.Customer Read1_Customer(bool isNullable, bool checkType) { if (isNullable && ReadNull()) return null; if (checkType) { System.Xml.XmlQualifiedName t = GetXsiType(); if (t == null || ((object) ((System.Xml.XmlQualifiedName)t).Name == (object)id1_Customer && (object) ((System.Xml.XmlQualifiedName)t).Namespace == (object)id2_Item)) ; else throw CreateUnknownTypeException((System.Xml.XmlQualifiedName)t); } Mvp.Xml.Design.Tests.Customer o = new Mvp.Xml.Design.Tests.Customer(); 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(); while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) { if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (!paramsRead[0] && ((object) Reader.LocalName == (object)id3_FirstName && (object) Reader.NamespaceURI == (object)id2_Item)) { o.@FirstName = Reader.ReadElementString(); paramsRead[0] = true; } else if (!paramsRead[1] && ((object) Reader.LocalName == (object)id4_LastName && (object) Reader.NamespaceURI == (object)id2_Item)) { o.@LastName = Reader.ReadElementString(); paramsRead[1] = true; } else { UnknownNode((object)o); } } else { UnknownNode((object)o); } Reader.MoveToContent(); } ReadEndElement(); return o; } /// <remarks/> protected virtual System.Object Read2_Object(bool isNullable, bool checkType) { if (isNullable && ReadNull()) return null; if (checkType) { System.Xml.XmlQualifiedName t = GetXsiType(); if (t == null) return ReadTypedPrimitive(new System.Xml.XmlQualifiedName("anyType", "http://www.w3.org/2001/XMLSchema")); else if (((object) ((System.Xml.XmlQualifiedName)t).Name == (object)id1_Customer && (object) ((System.Xml.XmlQualifiedName)t).Namespace == (object)id2_Item)) return Read1_Customer(isNullable, false); else return ReadTypedPrimitive((System.Xml.XmlQualifiedName)t); } System.Object o = new System.Object(); bool[] paramsRead = new bool[0]; while (Reader.MoveToNextAttribute()) { if (!IsXmlnsAttribute(Reader.Name)) { UnknownNode((object)o); } } Reader.MoveToElement(); if (Reader.IsEmptyElement) { Reader.Skip(); return o; } Reader.ReadStartElement(); Reader.MoveToContent(); while (Reader.NodeType != System.Xml.XmlNodeType.EndElement) { if (Reader.NodeType == System.Xml.XmlNodeType.Element) { UnknownNode((object)o); } else { UnknownNode((object)o); } Reader.MoveToContent(); } ReadEndElement(); return o; } protected override void InitCallbacks() { } protected internal object Read4_Customer() { object o = null; Reader.MoveToContent(); if (Reader.NodeType == System.Xml.XmlNodeType.Element) { if (((object) Reader.LocalName == (object)id1_Customer && (object) Reader.NamespaceURI == (object)id2_Item)) { o = Read1_Customer(true, true); } else { throw CreateUnknownNodeException(); } } else { UnknownNode(null); } return (object)o; } System.String id1_Customer; System.String id4_LastName; System.String id3_FirstName; System.String id2_Item; protected override void InitIDs() { id1_Customer = Reader.NameTable.Add(@"Customer"); id4_LastName = Reader.NameTable.Add(@"LastName"); id3_FirstName = Reader.NameTable.Add(@"FirstName"); id2_Item = Reader.NameTable.Add(@""); } } public class Writer : System.Xml.Serialization.XmlSerializationWriter { void Write1_Customer(string n, string ns, Mvp.Xml.Design.Tests.Customer 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(Mvp.Xml.Design.Tests.Customer)) ; else { throw CreateUnknownTypeException(o); } } WriteStartElement(n, ns, o); if (needType) WriteXsiType(@"Customer", @""); WriteElementString(@"FirstName", @"", ((System.String)o.@FirstName)); WriteElementString(@"LastName", @"", ((System.String)o.@LastName)); WriteEndElement(o); } void Write2_Object(string n, string ns, System.Object 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(System.Object)) ; else if (t == typeof(Mvp.Xml.Design.Tests.Customer)) { Write1_Customer(n, ns, (Mvp.Xml.Design.Tests.Customer)o, isNullable, true); return; } else { WriteTypedPrimitive(n, ns, o, true); return; } } WriteStartElement(n, ns, o); WriteEndElement(o); } protected override void InitCallbacks() { } protected internal void Write3_Customer(object o) { WriteStartDocument(); if (o == null) { WriteNullTagLiteral(@"Customer", @""); return; } TopLevelElement(); Write1_Customer(@"Customer", @"", ((Mvp.Xml.Design.Tests.Customer)o), true, false); } } /// <remarks/> } public class CustomerReader : CustomerSerializer.Reader { /// <remarks/> protected override Mvp.Xml.Design.Tests.Customer Read1_Customer(bool isNullable, bool checkType) { Mvp.Xml.Design.Tests.Customer obj = base.Read1_Customer(isNullable, checkType); CustomerDeserializedHandler handler = CustomerDeserialized; if (handler != null) handler(obj); return obj; } /// <summary>Reads an object of type Mvp.Xml.Design.Tests.Customer.</summary> internal Mvp.Xml.Design.Tests.Customer Read() { return (Mvp.Xml.Design.Tests.Customer) Read4_Customer(); } /// /// <remarks/> public event CustomerDeserializedHandler CustomerDeserialized; } /// /// <remarks/> public delegate void CustomerDeserializedHandler(Mvp.Xml.Design.Tests.Customer customer); public class CustomerWriter : CustomerSerializer.Writer { /// <summary>Writes an object of type Mvp.Xml.Design.Tests.Customer.</summary> internal void Write(Mvp.Xml.Design.Tests.Customer obj) { Write3_Customer(obj); }} } --- NEW FILE: Design.Tests.csproj --- <VisualStudioProject> <CSHARP ProjectType = "Local" ProductVersion = "7.10.3077" SchemaVersion = "2.0" ProjectGuid = "{4C7101B3-6736-46B1-B1AD-9FE4E2F685D5}" > <Build> <Settings ApplicationIcon = "" AssemblyKeyContainerName = "" AssemblyName = "Mvp.Xml.Design.Tests" AssemblyOriginatorKeyFile = "" DefaultClientScript = "JScript" DefaultHTMLPageLayout = "Grid" DefaultTargetSchema = "IE50" DelaySign = "false" OutputType = "Library" PreBuildEvent = "" PostBuildEvent = "" RootNamespace = "Mvp.Xml.Design.Tests" RunPostBuildEvent = "OnBuildSuccess" StartupObject = "" > <Config Name = "Debug" AllowUnsafeBlocks = "false" BaseAddress = "285212672" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "DEBUG;TRACE" DocumentationFile = "" DebugSymbols = "true" FileAlignment = "4096" IncrementalBuild = "false" NoStdLib = "false" NoWarn = "" Optimize = "false" OutputPath = "bin\Debug\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> <Config Name = "Release" AllowUnsafeBlocks = "false" BaseAddress = "285212672" CheckForOverflowUnderflow = "false" ConfigurationOverrideFile = "" DefineConstants = "TRACE" DocumentationFile = "" DebugSymbols = "false" FileAlignment = "4096" IncrementalBuild = "false" NoStdLib = "false" NoWarn = "" Optimize = "true" OutputPath = "bin\Release\" RegisterForComInterop = "false" RemoveIntegerChecks = "false" TreatWarningsAsErrors = "false" WarningLevel = "4" /> </Settings> <References> <Reference Name = "System" AssemblyName = "System" HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.dll" /> <Reference Name = "System.Data" AssemblyName = "System.Data" HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.Data.dll" /> <Reference Name = "System.XML" AssemblyName = "System.Xml" HintPath = "C:\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll" /> <Reference Name = "nunit.framework" AssemblyName = "nunit.framework" HintPath = "C:\Program Files\NUnit 2.2\bin\nunit.framework.dll" AssemblyFolderKey = "hklm\dn\nunit.framework" /> </References> </Build> <Files> <Include> <File RelPath = "AssemblyInfo.cs" SubType = "Code" BuildAction = "Compile" /> <File RelPath = "Customer.cs" SubType = "Code" BuildAction = "Compile" Generator = "Mvp.Xml.XGen" LastGenOutput = "Customer.Serialization.cs" /> <File RelPath = "Customer.Serialization.cs" DependentUpon = "Customer.cs" SubType = "Code" BuildAction = "Compile" AutoGen = "True" /> <File RelPath = "TestSerialization.cs" SubType = "Code" BuildAction = "Compile" /> </Include> </Files> </CSHARP> </VisualStudioProject> --- NEW FILE: Design.Tests.sln --- Microsoft Visual Studio Solution File, Format Version 8.00 Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Design", "..\src\Design.csproj", "{A379C40D-C984-4E63-933A-BE96E9A599B7}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Project("{54435603-DBB4-11D2-8724-00A0C9A8B90C}") = "Setup", "..\setup\setup.vdproj", "{0836E643-A9ED-421E-8426-1CB68F125B66}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Design.Tests", "Design.Tests.csproj", "{4C7101B3-6736-46B1-B1AD-9FE4E2F685D5}" ProjectSection(ProjectDependencies) = postProject EndProjectSection EndProject Global GlobalSection(SolutionConfiguration) = preSolution Debug = Debug Release = Release EndGlobalSection GlobalSection(ProjectConfiguration) = postSolution {A379C40D-C984-4E63-933A-BE96E9A599B7}.Debug.ActiveCfg = Debug|.NET {A379C40D-C984-4E63-933A-BE96E9A599B7}.Debug.Build.0 = Debug|.NET {A379C40D-C984-4E63-933A-BE96E9A599B7}.Release.ActiveCfg = Release|.NET {A379C40D-C984-4E63-933A-BE96E9A599B7}.Release.Build.0 = Release|.NET {0836E643-A9ED-421E-8426-1CB68F125B66}.Debug.ActiveCfg = Debug {0836E643-A9ED-421E-8426-1CB68F125B66}.Release.ActiveCfg = Release {4C7101B3-6736-46B1-B1AD-9FE4E2F685D5}.Debug.ActiveCfg = Debug|.NET {4C7101B3-6736-46B1-B1AD-9FE4E2F685D5}.Debug.Build.0 = Debug|.NET {4C7101B3-6736-46B1-B1AD-9FE4E2F685D5}.Release.ActiveCfg = Release|.NET {4C7101B3-6736-46B1-B1AD-9FE4E2F685D5}.Release.Build.0 = Release|.NET EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution EndGlobalSection GlobalSection(ExtensibilityAddIns) = postSolution EndGlobalSection EndGlobal --- NEW FILE: Customer.cs --- using System; namespace Mvp.Xml.Design.Tests { public class Customer { public string FirstName { get { return _name; } set { _name = value; } } string _name; public string LastName { get { return _lname; } set { _lname = value; } } string _lname; } } --- NEW FILE: TestSerialization.cs --- using System; using NUnit.Framework; namespace Mvp.Xml.Design.Tests { [TestFixture] public class TestSerialization { [Test] public void SerializePubs() { } } } --- NEW FILE: AssemblyInfo.cs --- using System.Reflection; using System.Runtime.CompilerServices; // // General Information about an assembly is controlled through the following // set of attributes. Change these attribute values to modify the information // associated with an assembly. // [assembly: AssemblyTitle("")] [assembly: AssemblyDescription("")] [assembly: AssemblyConfiguration("")] [assembly: AssemblyCompany("")] [assembly: AssemblyProduct("")] [assembly: AssemblyCopyright("")] [assembly: AssemblyTrademark("")] [assembly: AssemblyCulture("")] // // Version information for an assembly consists of the following four values: // // Major Version // Minor Version // Build Number // Revision // // You can specify all the values or you can default the Revision and Build Numbers // by using the '*' as shown below: [assembly: AssemblyVersion("1.0.*")] // // In order to sign your assembly you must specify a key to use. Refer to the // Microsoft .NET Framework documentation for more information on assembly signing. // // Use the attributes below to control which key is used for signing. // // Notes: // (*) If no key is specified, the assembly is not signed. // (*) KeyName refers to a key that has been installed in the Crypto Service // Provider (CSP) on your machine. KeyFile refers to a file which contains // a key. // (*) If the KeyFile and the KeyName values are both specified, the // following processing occurs: // (1) If the KeyName can be found in the CSP, that key is used. // (2) If the KeyName does not exist and the KeyFile does exist, the key // in the KeyFile is installed into the CSP and used. // (*) In order to create a KeyFile, you can use the sn.exe (Strong Name) utility. // When specifying the KeyFile, the location of the KeyFile should be // relative to the project output directory which is // %Project Directory%\obj\<configuration>. For example, if your KeyFile is // located in the project directory, you would specify the AssemblyKeyFile // attribute as [assembly: AssemblyKeyFile("..\\..\\mykey.snk")] // (*) Delay Signing is an advanced option - see the Microsoft .NET Framework // documentation for more information on this. // [assembly: AssemblyDelaySign(false)] [assembly: AssemblyKeyFile("")] [assembly: AssemblyKeyName("")] |