diff options
author | Atsushi Eno <atsushieno@gmail.com> | 2010-07-06 12:59:28 +0400 |
---|---|---|
committer | Atsushi Eno <atsushieno@gmail.com> | 2010-07-06 12:59:28 +0400 |
commit | 4efe543e9fa839fd09d23cde0c95196ca6d1b2bb (patch) | |
tree | 033d070baa8476c030ffd0c67eec021027c524dc /mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher | |
parent | 13e534136391927d966880cf42c868b205d20bf3 (diff) |
2010-07-06 Atsushi Enomoto <atsushi@ximian.com>
* 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
Diffstat (limited to 'mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher')
-rw-r--r-- | mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog | 4 | ||||
-rw-r--r-- | mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs | 28 |
2 files changed, 30 insertions, 2 deletions
diff --git a/mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog b/mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog index 6fa25ef26a0..96e6faa96f8 100644 --- a/mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog +++ b/mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/ChangeLog @@ -1,3 +1,7 @@ +2010-07-06 Atsushi Enomoto <atsushi@ximian.com> + + * WebMessageFormatter.cs : add NET_2_1 profile build. + 2010-05-24 Atsushi Enomoto <atsushi@ximian.com> * JsonQueryStringConverter.cs : objects are regarded serializable as diff --git a/mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs b/mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs index ba802e34c03..485e875832c 100644 --- a/mcs/class/System.ServiceModel.Web/System.ServiceModel.Dispatcher/WebMessageFormatter.cs +++ b/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 |