SoapFormatter
来源:互联网 发布:电脑ps软件6 编辑:程序博客网 时间:2024/06/04 18:34
- [assembly:System.CLSCompliant(true)]
- namespace System.Runtime.Serialization.Formatters.Soap
- {
- using System;
- using System.Runtime.Serialization.Formatters;
- using System.IO;
- using System.Reflection;
- using System.Globalization;
- using System.Collections;
- using System.Runtime.Serialization;
- using System.Runtime.Remoting;
- using System.Runtime.Remoting.Messaging;
- using System.Text;
-
- sealed public class SoapFormatter : IRemotingFormatter
- {
- private SoapParser soapParser = null;
- private ISurrogateSelector m_surrogates;
- private StreamingContext m_context;
- private FormatterTypeStyle m_typeFormat = FormatterTypeStyle.TypesWhenNeeded;
- private ISoapMessage m_topObject = null;
-
- private FormatterAssemblyStyle m_assemblyFormat = FormatterAssemblyStyle.Full;
- private SerializationBinder m_binder;
- private Stream currentStream = null;
-
-
-
-
- public ISoapMessage TopObject
- {
- get {return m_topObject;}
- set {m_topObject = value;}
- }
-
-
-
- public FormatterTypeStyle TypeFormat
- {
- get {return m_typeFormat;}
- set
- {
-
-
- if (value == FormatterTypeStyle.TypesWhenNeeded)
- m_typeFormat = FormatterTypeStyle.TypesWhenNeeded;
- else
- m_typeFormat |= value;
- }
- }
-
-
-
- public FormatterAssemblyStyle AssemblyFormat
- {
- get {return m_assemblyFormat;}
- set {m_assemblyFormat = value;}
- }
-
-
-
- public SoapFormatter()
- {
- m_surrogates=null;
- m_context = new StreamingContext(StreamingContextStates.All);
- }
-
-
- public SoapFormatter(ISurrogateSelector selector, StreamingContext context)
- {
- m_surrogates = selector;
- m_context = context;
- }
-
-
- public Object Deserialize(Stream serializationStream)
- {
- return Deserialize(serializationStream, null);
- }
-
-
- public Object Deserialize(Stream serializationStream, HeaderHandler handler) {
- InternalST.InfoSoap("Enter SoapFormatter.Deserialize ");
- if (serializationStream==null) {
- throw new ArgumentNullException("serializationStream");
- }
- if (serializationStream.CanSeek && (serializationStream.Length == 0))
- throw new SerializationException(SoapUtil.GetResourceString("Serialization_Stream"));
- InternalST.Soap( this, "Deserialize Entry");
- InternalFE formatterEnums = new InternalFE();
- formatterEnums.FEtypeFormat = m_typeFormat;
- formatterEnums.FEtopObject = m_topObject;
- formatterEnums.FEserializerTypeEnum = InternalSerializerTypeE.Soap;
- formatterEnums.FEassemblyFormat = m_assemblyFormat;
- ObjectReader sor = new ObjectReader(serializationStream, m_surrogates, m_context, formatterEnums, m_binder);
-
-
-
-
- if ((soapParser == null) || (serializationStream != currentStream))
- {
- soapParser = new SoapParser(serializationStream);
- currentStream = serializationStream;
- }
- soapParser.Init(sor);
- Object obj = sor.Deserialize(handler, soapParser);
- InternalST.InfoSoap("Leave SoapFormatter.Deserialize ");
- return obj;
- }
-
- public void Serialize(Stream serializationStream, Object graph)
- {
- Serialize(serializationStream, graph, null);
- }
-
-
-
- public void Serialize(Stream serializationStream, Object graph, Header[] headers)
- {
- InternalST.InfoSoap("Enter SoapFormatter.Serialize ");
- if (serializationStream==null) {
- throw new ArgumentNullException("serializationStream");
- }
- InternalST.Soap( this, "Serialize Entry");
- InternalFE formatterEnums = new InternalFE();
- formatterEnums.FEtypeFormat = m_typeFormat;
- formatterEnums.FEtopObject = m_topObject;
- formatterEnums.FEserializerTypeEnum = InternalSerializerTypeE.Soap;
- formatterEnums.FEassemblyFormat = m_assemblyFormat;
- ObjectWriter sow = new ObjectWriter(serializationStream, m_surrogates, m_context, formatterEnums);
- sow.Serialize(graph, headers, new SoapWriter(serializationStream));
- InternalST.InfoSoap("Leave SoapFormatter.Serialize ");
- }
-
- public ISurrogateSelector SurrogateSelector {
- get {
- return m_surrogates;
- }
- set {
- m_surrogates = value;
- }
- }
-
- public SerializationBinder Binder {
- get {
- return m_binder;
- }
- set {
- m_binder=value;
- }
- }
-
- public StreamingContext Context {
- get {
- return m_context;
- }
- set {
- m_context = value;
- }
- }
- }
- }
- SoapFormatter
- 使用SoapFormatter进行序列化
- [C#]BinaryFormatter、SoapFormatter、XML3种序列化
- 对象序列化 BinaryFormatter、XmlSerializer、SoapFormatter
- C#使用SoapFormatter序列化对象
- BinaryFormatter、SoapFormatter、XML3种序列化
- SoapFormatter 和 BinaryFormatter 序列化对象
- 化零为整WCF(9) - 序列化(DataContractSerializer, XmlSerializer, DataContractJsonSerializer, SoapFormatter, BinaryFormatter)
- 化零为整WCF(9) - 序列化(DataContractSerializer, XmlSerializer, DataContractJsonSerializer, SoapFormatter, BinaryFormatter)
- 化零为整WCF(9) - 序列化(DataContractSerializer, XmlSerializer, DataContractJsonSerializer, SoapFormatter, BinaryFormatter)
- WCF(10):序列化(DataContractSerializer, XmlSerializer, DataContractJsonSerializer, SoapFormatter, Binary
- WCF - 序列化(DataContractSerializer, XmlSerializer, DataContractJsonSerializer, SoapFormatter, Binar
- 01-Remoting之序列化(BinaryFormatter,SoapFormatter,XmlSerializer)
- C# 串行化与反串行化--使用SoapFormatter进行串行化
- C# 串行化与反串行化--使用SoapFormatter进行串行化
- C#SoapFormatter序列化一例:将图片读写入xml文件,并能根据需要在PictureBox中按比例缩小显示
- 运用ajax提示未定义
- 设计模式简单代码之Flyweight模式(二)
- JXTA v2.5技术手册
- c++ string类
- Opera 9.61 build 10463 正式版
- SoapFormatter
- 禁止刷新本页的方法
- oracle-V$session 表的妙用
- 怎么把pdf文档转成word文档
- 今天我的博客新开张啦。呵呵
- ByteBufferPool.cs
- 关于SQL Server存储过程的说明(基础)
- oracle-修改oracle 150 的最大连接数
- (3上)Silverlight开发工具Microsoft Expression Blend 2 之“States和Object面板简单“按钮””