Browse Source

2010-07-06 Atsushi Enomoto <[email protected]>

	* DataContractJsonSerializer_2_1.cs : add extra methods for
	  Sys.SM.Web.Extensions build.

	* WebMessageFormatter.cs : add NET_2_1 profile build.

	* AssemblyInfo.cs : InternalVisibleTo System.ServiceModel.Web.Extensions.


svn path=/trunk/mcs/; revision=159943
Atsushi Eno 15 years ago
parent
commit
4efe543e9f

+ 1 - 0
mcs/class/System.ServiceModel.Web/Assembly/AssemblyInfo.cs

@@ -62,6 +62,7 @@ using System.Runtime.InteropServices;
 
 #if NET_2_1
 [assembly: InternalsVisibleTo ("System.Json, PublicKey=00240000048000009400000006020000002400005253413100040000010001008D56C76F9E8649383049F383C44BE0EC204181822A6C31CF5EB7EF486944D032188EA1D3920763712CCB12D75FB77E9811149E6148E5D32FBAAB37611C1878DDC19E20EF135D0CB2CFF2BFEC3D115810C3D9069638FE4BE215DBF795861920E5AB6F7DB2E2CEEF136AC23D5DD2BF031700AEC232F6C6B1C785B4305C123B37AB")]
+[assembly: InternalsVisibleTo ("System.ServiceModel.Web.Extensions, PublicKey=0024000004800000940000000602000000240000525341310004000001000100b5fc90e7027f67871e773a8fde8938c81dd402ba65b9201d60593e96c492651e889cc13f1415ebb53fac1131ae0bd333c5ee6021672d9718ea31a8aebd0da0072f25d87dba6fc90ffd598ed4da35e44c398c454307e8e33b8426143daec9f596836f97c8f74750e5975c64e2189f45def46b2a2b1247adc3652bf5c308055da9")]
 #else
 [assembly: InternalsVisibleTo ("dummy-System.Json, PublicKey=00240000048000009400000006020000002400005253413100040000010001008D56C76F9E8649383049F383C44BE0EC204181822A6C31CF5EB7EF486944D032188EA1D3920763712CCB12D75FB77E9811149E6148E5D32FBAAB37611C1878DDC19E20EF135D0CB2CFF2BFEC3D115810C3D9069638FE4BE215DBF795861920E5AB6F7DB2E2CEEF136AC23D5DD2BF031700AEC232F6C6B1C785B4305C123B37AB")]
 #endif

+ 4 - 0
mcs/class/System.ServiceModel.Web/Assembly/ChangeLog

@@ -1,3 +1,7 @@
+2010-07-06  Atsushi Enomoto  <[email protected]>
+
+	* AssemblyInfo.cs : InternalVisibleTo System.ServiceModel.Web.Extensions.
+
 2010-03-10  Atsushi Enomoto  <[email protected]>
 
 	* AssemblyInfo.cs: added InternalVisibleTo(System.Json). Also added

+ 5 - 0
mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/ChangeLog

@@ -1,3 +1,8 @@
+2010-07-06  Atsushi Enomoto  <[email protected]>
+
+	* DataContractJsonSerializer_2_1.cs : add extra methods for
+	  Sys.SM.Web.Extensions build.
+
 2010-07-06  Atsushi Enomoto  <[email protected]>
 
 	* JsonReader.cs : do not keep Attribute state once Read() is called.

+ 24 - 1
mcs/class/System.ServiceModel.Web/System.Runtime.Serialization.Json/DataContractJsonSerializer_2_1.cs

@@ -72,7 +72,18 @@ namespace System.Runtime.Serialization.Json {
 		{
 			var r = (JsonReader) JsonReaderWriterFactory.CreateJsonReader (stream, XmlDictionaryReaderQuotas.Max);
 			r.LameSilverlightLiteralParser = true;
+			return ReadObject (r);
+		}
 
+		// FIXME: should be internal
+		public object ReadObject (XmlReader r)
+		{
+			return ReadObject (XmlDictionaryReader.CreateDictionaryReader (r));
+		}
+		
+		// FIXME: should be internal
+		public object ReadObject (XmlDictionaryReader r)
+		{
 			try {
 				r.MoveToContent ();
 				if (!r.IsStartElement ("root", String.Empty)) {
@@ -95,6 +106,19 @@ namespace System.Runtime.Serialization.Json {
 		public void WriteObject (Stream stream, object graph)
 		{
 			using (var writer = JsonReaderWriterFactory.CreateJsonWriter (stream)) {
+				WriteObject (writer, graph);
+			}
+		}
+		
+		// FIXME: should be internal
+		public void WriteObject (XmlWriter writer, object graph)
+		{
+			WriteObject (XmlDictionaryWriter.CreateDictionaryWriter (writer), graph);
+		}
+		
+		// FIXME: should be internal
+		public void WriteObject (XmlDictionaryWriter writer, object graph)
+		{
 				try {
 					writer.WriteStartElement ("root");
 					new JsonSerializationWriter (this, writer, type, false).WriteObjectContent (graph, true, false);
@@ -110,7 +134,6 @@ namespace System.Runtime.Serialization.Json {
 				} catch (Exception ex) {
 					throw new SerializationException (String.Format ("There was an error during serialization for object of type {0}", graph != null ? graph.GetType () : null), ex);
 				}
-			}
 		}
 	}
 }

+ 4 - 0
mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog

@@ -1,3 +1,7 @@
+2010-07-06  Atsushi Enomoto  <[email protected]>
+
+	* WebMessageFormatter.cs : add NET_2_1 profile build.
+
 2010-05-24  Atsushi Enomoto  <[email protected]>
 
 	* JsonQueryStringConverter.cs : objects are regarded serializable as

+ 26 - 2
mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs

@@ -38,6 +38,10 @@ using System.ServiceModel.Web;
 using System.Text;
 using System.Xml;
 
+#if NET_2_1
+using XmlObjectSerializer = System.Object;
+#endif
+
 namespace System.ServiceModel.Description
 {
 	internal abstract class WebMessageFormatter
@@ -56,10 +60,12 @@ namespace System.ServiceModel.Description
 			this.converter = converter;
 			this.behavior = behavior;
 			ApplyWebAttribute ();
+#if !NET_2_1
 			// This is a hack for WebScriptEnablingBehavior
 			var jqc = converter as JsonQueryStringConverter;
 			if (jqc != null)
 				BodyName = jqc.CustomWrapperName;
+#endif
 		}
 
 		void ApplyWebAttribute ()
@@ -313,7 +319,13 @@ namespace System.ServiceModel.Description
 						reader.ReadStartElement (md.Body.WrapperName, md.Body.WrapperNamespace);
 				}
 
+#if NET_2_1
+				var ret = (serializer is DataContractJsonSerializer) ?
+					((DataContractJsonSerializer) serializer).ReadObject (reader) :
+					((DataContractSerializer) serializer).ReadObject (reader, true);
+#else
 				var ret = serializer.ReadObject (reader, true);
+#endif
 
 				if (IsResponseBodyWrapped)
 					reader.ReadEndElement ();
@@ -360,7 +372,7 @@ namespace System.ServiceModel.Description
 					writer.WriteStartElement ("root");
 					writer.WriteAttributeString ("type", "object");
 				}
-				serializer.WriteObject (writer, value);
+				WriteObject (serializer, writer, value);
 				if (name != null)
 					writer.WriteEndElement ();
 			}
@@ -369,10 +381,22 @@ namespace System.ServiceModel.Description
 			{
 				if (name != null)
 					writer.WriteStartElement (name, ns);
-				serializer.WriteObject (writer, value);
+				WriteObject (serializer, writer, value);
 				if (name != null)
 					writer.WriteEndElement ();
 			}
+
+			void WriteObject (XmlObjectSerializer serializer, XmlDictionaryWriter writer, object value)
+			{
+#if NET_2_1
+					if (serializer is DataContractJsonSerializer)
+						((DataContractJsonSerializer) serializer).WriteObject (writer, value);
+					else
+						((DataContractSerializer) serializer).WriteObject (writer, value);
+#else
+					serializer.WriteObject (writer, value);
+#endif
+			}
 		}
 
 #if !NET_2_1