本文整理汇总了C#中System.Runtime.Serialization.XmlObjectSerializer类的典型用法代码示例。如果您正苦于以下问题:C# XmlObjectSerializer类的具体用法?C# XmlObjectSerializer怎么用?C# XmlObjectSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlObjectSerializer类属于System.Runtime.Serialization命名空间,在下文中一共展示了XmlObjectSerializer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: XmlObjectSerializerBodyWriter
public XmlObjectSerializerBodyWriter (
object body, XmlObjectSerializer formatter)
: base (true)
{
this.body = body;
this.formatter = formatter;
}
示例2: XmlObjectSerializerHeader
private XmlObjectSerializerHeader(XmlObjectSerializer serializer, bool mustUnderstand, string actor, bool relay)
{
this.syncRoot = new object();
if (actor == null)
{
throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("actor");
}
this.mustUnderstand = mustUnderstand;
this.relay = relay;
this.serializer = serializer;
this.actor = actor;
if (actor == EnvelopeVersion.Soap12.UltimateDestinationActor)
{
this.isOneOneSupported = false;
this.isOneTwoSupported = true;
}
else if (actor == EnvelopeVersion.Soap12.NextDestinationActorValue)
{
this.isOneOneSupported = false;
this.isOneTwoSupported = true;
}
else if (actor == EnvelopeVersion.Soap11.NextDestinationActorValue)
{
this.isOneOneSupported = true;
this.isOneTwoSupported = false;
}
else
{
this.isOneOneSupported = true;
this.isOneTwoSupported = true;
this.isNoneSupported = true;
}
}
示例3: Deserialize
public static object Deserialize(string xmlContent, string serializerType)
{
object returnValue = null;
SerializerTypes serializerTypeValue;
Type instanceType;
GetSerializerDetails(serializerType, out serializerTypeValue, out instanceType);
if (serializerTypeValue == SerializerTypes.XmlSerializer)
{
StringReader sww = new StringReader(xmlContent);
XmlReader reader = XmlReader.Create(sww);
System.Xml.Serialization.XmlSerializer serializer = new System.Xml.Serialization.XmlSerializer(instanceType);
returnValue = serializer.Deserialize(reader);
}
else if (serializerTypeValue == SerializerTypes.XmlObjectSerializer)
{
XmlObjectSerializer serializer = new XmlObjectSerializer();
returnValue = serializer.Deserialize(xmlContent, true);
}
else
{
if (instanceType == typeof(string))
{
returnValue = xmlContent;
}
else
{
var method = instanceType.GetMethod("Parse", System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public);
returnValue = method.Invoke(null, new object[] { xmlContent });
}
}
return returnValue;
}
示例4: MessageSubscribtionInfo
public MessageSubscribtionInfo(DataContractKey contractKey, ICallHandler handler, XmlObjectSerializer serializer, bool receiveSelfPublish, IEnumerable<BusHeader> filterHeaders)
{
_handler = handler;
_serializer = serializer;
_filterInfo = new MessageFilterInfo(contractKey, receiveSelfPublish, filterHeaders);
}
示例5: WebFormatterSerializationContext
private WebFormatterSerializationContext(XmlObjectSerializer xmlSerializer)
{
if (xmlSerializer is DataContractJsonSerializer)
ContentFormat = SerializationFormat.Json;
else
ContentFormat = SerializationFormat.Xml;
XmlSerializer = xmlSerializer;
}
示例6: CreateHeader
public static MessageHeader CreateHeader(string name, string ns, object value, XmlObjectSerializer serializer, bool mustUnderstand, string actor, bool relay)
{
if (serializer == null)
{
throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("serializer"));
}
return new XmlObjectSerializerHeader(name, ns, value, serializer, mustUnderstand, actor, relay);
}
示例7: XmlObjectSerializerContext
internal XmlObjectSerializerContext(XmlObjectSerializer serializer, int maxItemsInObjectGraph, StreamingContext streamingContext, bool ignoreExtensionDataObject, DataContractResolver dataContractResolver)
{
this.serializer = serializer;
this.itemCount = 1;
this.maxItemsInObjectGraph = maxItemsInObjectGraph;
this.streamingContext = streamingContext;
this.ignoreExtensionDataObject = ignoreExtensionDataObject;
this.dataContractResolver = dataContractResolver;
}
示例8: XmlObjectSerializerFault
public XmlObjectSerializerFault(FaultCode code, FaultReason reason, object detail, XmlObjectSerializer serializer, string actor, string node)
{
this.code = code;
this.reason = reason;
this.detail = detail;
this.serializer = serializer;
this.actor = actor;
this.node = node;
}
示例9: XmlObjectSerializerContext
internal XmlObjectSerializerContext(XmlObjectSerializer serializer, int maxItemsInObjectGraph, StreamingContext streamingContext, bool ignoreExtensionDataObject, System.Runtime.Serialization.DataContractResolver dataContractResolver)
{
this.scopedKnownTypes = new ScopedKnownTypes();
this.serializer = serializer;
this.itemCount = 1;
this.maxItemsInObjectGraph = maxItemsInObjectGraph;
this.streamingContext = streamingContext;
this.ignoreExtensionDataObject = ignoreExtensionDataObject;
this.dataContractResolver = dataContractResolver;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:10,代码来源:XmlObjectSerializerContext.cs
示例10: JsonSerializer
public JsonSerializer(Type type, XmlObjectSerializer fallbackSerializer, bool isCompress,
SerializeContentTypes contentType)
{
this.type = type;
this.isCustomSerialization = true;
this.fallbackSerializer = fallbackSerializer;
m_IsCompress = isCompress;
m_ContentType = contentType;
}
示例11: WriteObject
/// <remarks>
/// DataContractJsonSerializer : XmlObjectSerializer (abstract)
/// DataContractSerializer : XmlObjectSerializer (abstract)
/// </remarks>
private string WriteObject(Location location, XmlObjectSerializer serializer)
{
var memoryStream = new System.IO.MemoryStream();
serializer.WriteObject(memoryStream, location);
memoryStream.Position = 0;
var reader = new System.IO.StreamReader(memoryStream);
var output = reader.ReadToEnd();
return output;
}
示例12: Serialize
static byte[] Serialize(object result, XmlObjectSerializer serializer)
{
byte[] body;
using (var stream = new MemoryStream())
{
serializer.WriteObject(stream, result);
body = stream.ToArray();
}
//hack to remove the type info from the json
var bodyString = Encoding.UTF8.GetString(body);
var toReplace = $", {result.GetType().Assembly.GetName().Name}";
bodyString = bodyString.Replace(toReplace, ", ServiceControl");
body = Encoding.UTF8.GetBytes(bodyString);
return body;
}
示例13: DeserializeClaimSet
public static ClaimSet DeserializeClaimSet(XmlDictionaryReader reader, SctClaimDictionary dictionary, XmlObjectSerializer serializer, XmlObjectSerializer claimSerializer)
{
if (reader.IsStartElement(dictionary.NullValue, dictionary.EmptyString))
{
reader.ReadElementString();
return null;
}
else if (reader.IsStartElement(dictionary.X509CertificateClaimSet, dictionary.EmptyString))
{
reader.ReadStartElement();
byte[] rawData = reader.ReadContentAsBase64();
reader.ReadEndElement();
return new X509CertificateClaimSet(new X509Certificate2(rawData), false);
}
else if (reader.IsStartElement(dictionary.SystemClaimSet, dictionary.EmptyString))
{
reader.ReadElementString();
return ClaimSet.System;
}
else if (reader.IsStartElement(dictionary.WindowsClaimSet, dictionary.EmptyString))
{
reader.ReadElementString();
return ClaimSet.Windows;
}
else if (reader.IsStartElement(dictionary.AnonymousClaimSet, dictionary.EmptyString))
{
reader.ReadElementString();
return ClaimSet.Anonymous;
}
else if (reader.IsStartElement(dictionary.ClaimSet, dictionary.EmptyString))
{
ClaimSet issuer = null;
List<Claim> claims = new List<Claim>();
reader.ReadStartElement();
if (reader.IsStartElement(dictionary.PrimaryIssuer, dictionary.EmptyString))
{
reader.ReadStartElement();
issuer = DeserializeClaimSet(reader, dictionary, serializer, claimSerializer);
reader.ReadEndElement();
}
while (reader.IsStartElement())
{
reader.ReadStartElement();
claims.Add(DeserializeClaim(reader, dictionary, claimSerializer));
reader.ReadEndElement();
}
reader.ReadEndElement();
return issuer != null ? new DefaultClaimSet(issuer, claims) : new DefaultClaimSet(claims);
}
else
{
return (ClaimSet)serializer.ReadObject(reader);
}
}
示例14: ReadHeaderObject
object ReadHeaderObject (Type type, XmlObjectSerializer serializer, XmlDictionaryReader reader)
{
// FIXME: it's a nasty workaround just to avoid UniqueId output as a string.
// Seealso MessageHeader.DefaultMessageHeader.OnWriteHeaderContents().
// Note that msg.Headers.GetHeader<UniqueId> () simply fails (on .NET too) and it is useless. The API is lame by design.
if (type == typeof (UniqueId))
return new UniqueId (reader.ReadElementContentAsString ());
else
return serializer.ReadObject (reader);
}
示例15: XmlObjectSerializerReadContextComplex
internal XmlObjectSerializerReadContextComplex(XmlObjectSerializer serializer, int maxItemsInObjectGraph, StreamingContext streamingContext, bool ignoreExtensionDataObject)
: base(serializer, maxItemsInObjectGraph, streamingContext, ignoreExtensionDataObject)
{
}