// Jean-Marc Andre (jean-marc.andre@polymtl.ca)\r
//\r
\r
+//\r
+// Permission is hereby granted, free of charge, to any person obtaining\r
+// a copy of this software and associated documentation files (the\r
+// "Software"), to deal in the Software without restriction, including\r
+// without limitation the rights to use, copy, modify, merge, publish,\r
+// distribute, sublicense, and/or sell copies of the Software, and to\r
+// permit persons to whom the Software is furnished to do so, subject to\r
+// the following conditions:\r
+// \r
+// The above copyright notice and this permission notice shall be\r
+// included in all copies or substantial portions of the Software.\r
+// \r
+// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,\r
+// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r
+// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r
+// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r
+// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r
+// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r
+// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r
+//\r
+\r
using System;\r
using System.IO;\r
using System.Reflection;\r
+using System.Runtime.InteropServices;\r
using System.Runtime.Remoting;\r
using System.Runtime.Serialization;\r
using System.Runtime.Remoting.Messaging;\r
using System.Xml.Serialization;\r
+using System.Threading;\r
+using System.Globalization;\r
\r
\r
namespace System.Runtime.Serialization.Formatters.Soap {\r
MethodCall, MethodResponse, ServerFault, NotRecognize\r
}\r
\r
- public class SoapFormatter: IRemotingFormatter, IFormatter {\r
- private ObjectWriter _objWriter;\r
- private SoapWriter _soapWriter;\r
+ public sealed class SoapFormatter: IRemotingFormatter, IFormatter {\r
private SerializationBinder _binder;\r
private StreamingContext _context;\r
private ISurrogateSelector _selector;\r
- private ISoapMessage _topObject;\r
+ private FormatterAssemblyStyle _assemblyFormat = FormatterAssemblyStyle.Full;\r
+ private FormatterTypeStyle _typeFormat = FormatterTypeStyle.TypesWhenNeeded;\r
+ private ISoapMessage _topObject = null;\r
\r
+ TypeFilterLevel _filterLevel = TypeFilterLevel.Low;\r
+\r
public SoapFormatter() {\r
- \r
+ _selector = null;\r
+ _context = new StreamingContext(StreamingContextStates.All);\r
}\r
\r
- public SoapFormatter(ISurrogateSelector selector, StreamingContext context):this() {\r
+ public SoapFormatter(ISurrogateSelector selector, StreamingContext context) {\r
_selector = selector;\r
_context = context;\r
}\r
\r
- ~SoapFormatter() {\r
- }\r
-\r
- \r
public object Deserialize(Stream serializationStream) {\r
return Deserialize(serializationStream, null);\r
}\r
\r
public object Deserialize(Stream serializationStream, HeaderHandler handler) {\r
- SoapParser parser = new SoapParser(serializationStream);\r
- SoapReader soapReader = new SoapReader(parser);\r
- soapReader.Binder = _binder;\r
- \r
- \r
- if(_topObject != null) soapReader.TopObject = _topObject;\r
- ObjectReader reader = new ObjectReader(_selector, _context, soapReader);\r
- parser.Run();\r
- object objReturn = reader.TopObject;\r
+ object objReturn = null;\r
+ SoapReader soapReader = new SoapReader(_binder, _selector, _context);\r
+ CultureInfo savedCi = CultureInfo.CurrentCulture;\r
+ try {\r
+ Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");\r
+ objReturn = soapReader.Deserialize(serializationStream, _topObject);\r
+ }\r
+ finally {\r
+ Thread.CurrentThread.CurrentCulture = savedCi;\r
+ }\r
return objReturn;\r
}\r
\r
throw new ArgumentNullException("serializationStream");\r
if(!serializationStream.CanWrite)\r
throw new SerializationException("Can't write in the serialization stream");\r
- _soapWriter = new SoapWriter(serializationStream);\r
- _objWriter = new ObjectWriter((ISoapWriter) _soapWriter, _selector, new StreamingContext(StreamingContextStates.File));\r
- _soapWriter.Writer = _objWriter;\r
- _objWriter.Serialize(graph);\r
+ if(graph == null)\r
+ throw new ArgumentNullException("graph");\r
+ SoapWriter soapWriter = new SoapWriter(serializationStream, _selector, _context, _topObject);\r
+ CultureInfo savedCi = CultureInfo.CurrentCulture;\r
+ try {\r
+ Thread.CurrentThread.CurrentCulture = new CultureInfo("en-US");\r
+ soapWriter.Serialize (graph, headers, _typeFormat, _assemblyFormat);\r
+ }\r
+ finally {\r
+ Thread.CurrentThread.CurrentCulture = savedCi;\r
+ }\r
\r
}\r
\r
}\r
}\r
\r
- \r
- //private methods\r
- \r
- // finish the work on the SoapMessage\r
- // fill the SoapMessage.ParamName array\r
- // fill the SoapMessage.ParamType array\r
- // convert the SoapMessage.ParamValue array items\r
- // to the right type if needed\r
+ [MonoTODO ("Interpret this")]\r
+ public TypeFilterLevel FilterLevel {\r
+ get {\r
+ return _filterLevel;\r
+ }\r
+ set {\r
+ _filterLevel = value;\r
+ }\r
+ }\r
\r
+ public FormatterAssemblyStyle AssemblyFormat\r
+ {\r
+ get {\r
+ return _assemblyFormat;\r
+ }\r
+ set {\r
+ _assemblyFormat = value;\r
+ }\r
+ }\r
+\r
+ public FormatterTypeStyle TypeFormat\r
+ {\r
+ get \r
+ {\r
+ return _typeFormat;\r
+ }\r
+ set \r
+ {\r
+ _typeFormat = value;\r
+ }\r
+ }\r
+\r
}\r
}\r