* SoapTypeMapper.cs: Added mappings for more primitive types.
authorLluis Sanchez <lluis@novell.com>
Mon, 25 Aug 2003 11:13:56 +0000 (11:13 -0000)
committerLluis Sanchez <lluis@novell.com>
Mon, 25 Aug 2003 11:13:56 +0000 (11:13 -0000)
* SoapWriter.cs: Use XmlSchema.Namespace and XmlSchema.InstanceNamespace
  instead of string constants.

svn path=/trunk/mcs/; revision=17575

mcs/class/System.Runtime.Serialization.Formatters.Soap/ChangeLog
mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapTypeMapper.cs
mcs/class/System.Runtime.Serialization.Formatters.Soap/System.Runtime.Serialization.Formatters.Soap/SoapWriter.cs

index c1a3a00c6321dc63a44ba09883453f7631010105..99930f6d60b735b349ada12a831ef3910135e1a7 100644 (file)
@@ -1,3 +1,9 @@
+2003-08-25  Lluis Sanchez Gual  <lluis@ximian.com>
+
+       * SoapTypeMapper.cs: Added mappings for more primitive types.
+       * SoapWriter.cs: Use XmlSchema.Namespace and XmlSchema.InstanceNamespace
+         instead of string constants.
+
 2003-06-30  Jean-Marc Andre <jean-marc.andre@polymtl.ca>
        * SoapServices:
                removed because it is now included in the
index e5c9da532ead5d949d62e30bd15b04d8b01375be..bad2897af56a959aa173077df04ebe52efab5ca0 100644 (file)
@@ -11,6 +11,7 @@ using System.Reflection;
 using System.Collections;\r
 using System.Runtime.Remoting;\r
 using System.Xml.Serialization;\r
+using System.Xml.Schema;\r
 \r
 namespace System.Runtime.Serialization.Formatters.Soap {\r
        \r
@@ -26,7 +27,9 @@ namespace System.Runtime.Serialization.Formatters.Soap {
                // returns the SoapTypeMapping corresponding to the System.Type\r
                public static SoapTypeMapping GetSoapType(Type type) {\r
                        object rtnMapping;\r
-                       \r
+\r
+                       if (type.IsByRef) type = type.GetElementType ();\r
+\r
                        \r
                        if(type.IsArray){\r
                                        rtnMapping = _mappingTable[typeof(System.Array)];\r
@@ -35,7 +38,6 @@ namespace System.Runtime.Serialization.Formatters.Soap {
                                rtnMapping = (object) _mappingTable[type];\r
                                \r
                                if(rtnMapping == null){\r
-                                       \r
                                        string sTypeNamespace;\r
                                        AssemblyName assName = type.Assembly.GetName();\r
                                        if(assName.Name.StartsWith("mscorlib")) sTypeNamespace = "http://schemas.microsoft.com/clr/ns/"+type.Namespace;\r
@@ -79,6 +81,13 @@ namespace System.Runtime.Serialization.Formatters.Soap {
                        \r
                        return (Type)rtnObject;\r
                }\r
+\r
+               private static void RegisterSchemaType (Type type, string typeName, bool canBeValue, bool isPrimitive,bool isValueType,bool needId)\r
+               {\r
+                       SoapTypeMapping mapping =  new SoapTypeMapping (type, typeName, canBeValue, isPrimitive, isValueType, needId);\r
+                       _mappingTable.Add(type, mapping);\r
+                       _invertMappingTable.Add(mapping, type);\r
+               }\r
                \r
                // initialize the mapping tables\r
                private static void InitMappingTable() {\r
@@ -88,51 +97,26 @@ namespace System.Runtime.Serialization.Formatters.Soap {
                        mapping =  new SoapTypeMapping(typeof(string), "string", true, false, false, true);\r
                        _mappingTable.Add(typeof(string),mapping);\r
                        _invertMappingTable.Add(mapping, typeof(string));\r
-                       mapping =  new SoapTypeMapping(typeof(string), "string", "http://www.w3.org/2001/XMLSchema", true, false, false, true);\r
+                       mapping =  new SoapTypeMapping(typeof(string), "string", XmlSchema.Namespace, true, false, false, true);\r
                        _invertMappingTable.Add(mapping, typeof(string));\r
-                       \r
-                       // the primitive type "System.Int16"\r
-                       mapping =  new SoapTypeMapping(typeof(short), "short", "http://www.w3.org/2001/XMLSchema", true, true, true, false);\r
-                       _mappingTable.Add(typeof(short), mapping);\r
-                       _invertMappingTable.Add(mapping, typeof(short));\r
-                       \r
-                       // the primitive type "System.Int32"\r
-                       mapping =  new SoapTypeMapping(typeof(int), "int", "http://www.w3.org/2001/XMLSchema", true, true, true, false);\r
-                       _mappingTable.Add(typeof(int), mapping);\r
-                       _invertMappingTable.Add(mapping, typeof(int));\r
-                       \r
-                       // the primitive type "System.Boolean"\r
-                       mapping =  new SoapTypeMapping(typeof(bool), "boolean", "http://www.w3.org/2001/XMLSchema", true, true, true, false);\r
-                       _mappingTable.Add(typeof(bool), mapping);\r
-                       _invertMappingTable.Add(mapping, typeof(bool));\r
-                       \r
-                       // the primitive type "System.long"\r
-                       mapping =  new SoapTypeMapping(typeof(long), "long", "http://www.w3.org/2001/XMLSchema", true, true, true, false);\r
-                       _mappingTable.Add(typeof(long), mapping);\r
-                       _invertMappingTable.Add(mapping, typeof(long));\r
-                       \r
-                       // the primitive type "System.double"\r
-                       mapping =  new SoapTypeMapping(typeof(double), "double", "http://www.w3.org/2001/XMLSchema", true, true, true, false);\r
-                       _mappingTable.Add(typeof(double), mapping);\r
-                       _invertMappingTable.Add(mapping, typeof(double));\r
-                       \r
-                       // the primitive type "System.Char"\r
-                       mapping =  new SoapTypeMapping(typeof(Char), "Char", "http://www.w3.org/2001/XMLSchema", true, true, true, false);\r
-                       _mappingTable.Add(typeof(Char), mapping);\r
-                       _invertMappingTable.Add(mapping, typeof(Char));\r
-                       \r
-                       // the primitive type "System.Single"\r
-                       mapping = new SoapTypeMapping(typeof(System.Single), "float", "http://www.w3.org/2001/XMLSchema", true, true, true, false);\r
-                       _mappingTable.Add(typeof(System.Single), mapping);\r
-                       _invertMappingTable.Add(mapping, typeof(System.Single));\r
-                       \r
-                       mapping =  new SoapTypeMapping(typeof(System.Array), "Array", false, false, false, true);\r
-                       _mappingTable.Add(typeof(System.Array), mapping);\r
-                       _invertMappingTable.Add(mapping, typeof(System.Array));\r
-                       \r
-                       mapping = new SoapTypeMapping(typeof(object), "anyType", "http://www.w3.org/2001/XMLSchema", false, false, false, true);\r
-                       _mappingTable.Add(typeof(object), mapping);\r
-                       _invertMappingTable.Add(mapping, typeof(object));\r
+\r
+                       RegisterSchemaType (typeof(short), "short", true, true, true, false);\r
+                       RegisterSchemaType (typeof(ushort), "unsignedShort", true, true, true, false);\r
+                       RegisterSchemaType (typeof(int), "int", true, true, true, false);\r
+                       RegisterSchemaType (typeof(uint), "unsignedInt", true, true, true, false);\r
+                       RegisterSchemaType (typeof(long), "long", true, true, true, false);\r
+                       RegisterSchemaType (typeof(ulong), "unsignedLong", true, true, true, false);\r
+                       RegisterSchemaType (typeof(decimal), "decimal", true, true, true, false);\r
+                       RegisterSchemaType (typeof(sbyte), "byte", true, true, true, false);\r
+                       RegisterSchemaType (typeof(byte), "unsignedByte", true, true, true, false);\r
+                       RegisterSchemaType (typeof(DateTime), "dateTime", true, true, true, false);\r
+                       RegisterSchemaType (typeof(TimeSpan), "duration", true, true, true, false);\r
+                       RegisterSchemaType (typeof(double), "double", true, true, true, false);\r
+                       RegisterSchemaType (typeof(Char), "char", true, true, true, false);\r
+                       RegisterSchemaType (typeof(bool), "boolean", true, true, true, false);\r
+                       RegisterSchemaType (typeof(System.Single), "float", true, true, true, false);\r
+                       RegisterSchemaType (typeof(System.Array), "Array", false, false, false, true);\r
+                       RegisterSchemaType (typeof(object), "anyType", false, false, false, true);\r
                        \r
                        mapping = new SoapTypeMapping(typeof(System.Runtime.Serialization.Formatters.SoapFault), "Fault", "http://schemas.xmlsoap.org/soap/envelope/", false, false, false, true);\r
                        _mappingTable.Add(typeof(System.Runtime.Serialization.Formatters.SoapFault), mapping);\r
index 3a539d7d1acd3f4269acdf83a3ec635b1c99eaaa..acafaf8dc297e319b8cd5304714f380771a4b9c2 100755 (executable)
@@ -14,6 +14,7 @@ using System.Runtime.Remoting;
 using System.Runtime.Serialization;\r
 using System.Runtime.Serialization.Formatters;\r
 using System.Xml;\r
+using System.Xml.Schema;\r
 using System.Xml.Serialization;\r
 using System.Globalization;\r
 \r
@@ -107,6 +108,7 @@ namespace System.Runtime.Serialization.Formatters.Soap {
                                soapEntry.elementType = ElementType.Id;\r
                                _objectIds[objValue] = id;\r
                        }\r
+\r
                        \r
                        return soapEntry;\r
                }\r
@@ -235,7 +237,7 @@ namespace System.Runtime.Serialization.Formatters.Soap {
                        }\r
                        \r
                }\r
-               \r
+\r
                private void WriteElement(SoapSerializationEntry entry) {\r
                        _xmlWriter.WriteStartElement(entry.prefix, XmlConvert.EncodeNmToken(entry.elementName), entry.elementNamespace);\r
                        \r
@@ -258,6 +260,7 @@ namespace System.Runtime.Serialization.Formatters.Soap {
                        Done = DoneWithElementEvent;\r
                        SoapSerializationEntry entry = FillEntry(rootType, rootValue); //new SoapSerializationEntry();\r
                        if(rootType.IsArray) {\r
+\r
                                Done = DoneWithArray;\r
                                entry.IsArray = true;\r
                        }\r
@@ -305,8 +308,8 @@ namespace System.Runtime.Serialization.Formatters.Soap {
                        ArrayList lstAttr = new ArrayList();\r
                        _xmlWriter.WriteStartElement("SOAP-ENV", "Envelope",  "http://schemas.xmlsoap.org/soap/envelope/");\r
                        \r
-                       _xmlWriter.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");\r
-                       _xmlWriter.WriteAttributeString("xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema" );\r
+                       _xmlWriter.WriteAttributeString("xmlns", "xsi", null, XmlSchema.InstanceNamespace);\r
+                       _xmlWriter.WriteAttributeString("xmlns", "xsd", null, XmlSchema.Namespace );\r
                        _xmlWriter.WriteAttributeString("xmlns", "SOAP-ENC", null, "http://schemas.xmlsoap.org/soap/encoding/");\r
                        _xmlWriter.WriteAttributeString("xmlns", "SOAP-ENV", null, "http://schemas.xmlsoap.org/soap/envelope/");\r
                        _xmlWriter.WriteAttributeString("xmlns", "clr", null, "http://schemas.microsoft.com/soap/encoding/clr/1.0" );\r