本文整理汇总了C#中System.Runtime.Serialization.XmlObjectSerializer类的典型用法代码示例。如果您正苦于以下问题:C# XmlObjectSerializer类的具体用法?C# XmlObjectSerializer怎么用?C# XmlObjectSerializer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlObjectSerializer类属于System.Runtime.Serialization命名空间,在下文中一共展示了XmlObjectSerializer类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: XmlObjectSerializerBodyWriter
public XmlObjectSerializerBodyWriter (
object body, XmlObjectSerializer formatter)
: base (true)
{
this.body = body;
this.formatter = formatter;
}
开发者ID:nickchal,项目名称:pash,代码行数:7,代码来源:XmlObjectSerializerBodyWriter.cs
示例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;
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:33,代码来源:XmlObjectSerializerHeader.cs
示例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;
}
开发者ID:priestofpsi,项目名称:theDiary-Common-Framework,代码行数:33,代码来源:SerializationHelper.cs
示例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);
}
开发者ID:ronybot,项目名称:MessageBus,代码行数:7,代码来源:MessageSubscribtionInfo.cs
示例5: WebFormatterSerializationContext
private WebFormatterSerializationContext(XmlObjectSerializer xmlSerializer)
{
if (xmlSerializer is DataContractJsonSerializer)
ContentFormat = SerializationFormat.Json;
else
ContentFormat = SerializationFormat.Xml;
XmlSerializer = xmlSerializer;
}
开发者ID:richet,项目名称:WcfRestContrib,代码行数:8,代码来源:WebFormatterSerializationContext.cs
示例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);
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:8,代码来源:MessageHeader.cs
示例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;
}
开发者ID:yangjunhua,项目名称:mono,代码行数:9,代码来源:XmlObjectSerializerContext.cs
示例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;
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:9,代码来源:XmlObjectSerializerFault.cs
示例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;
}
开发者ID:JackFong,项目名称:GenericWcfServiceHostAndClient,代码行数:10,代码来源:JsonSerializer.cs
示例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;
}
开发者ID:dennido5,项目名称:70-483,代码行数:15,代码来源:TestClass.cs
示例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;
}
开发者ID:Particular,项目名称:ServiceControl.Plugin.Nsb6.Heartbeat,代码行数:19,代码来源:ServiceControlBackend.cs
示例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);
}
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:57,代码来源:SctClaimSerializer.cs
示例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);
}
开发者ID:pasko,项目名称:mono,代码行数:10,代码来源:BaseMessagesFormatter.cs
示例15: XmlObjectSerializerReadContextComplex
internal XmlObjectSerializerReadContextComplex(XmlObjectSerializer serializer, int maxItemsInObjectGraph, StreamingContext streamingContext, bool ignoreExtensionDataObject)
: base(serializer, maxItemsInObjectGraph, streamingContext, ignoreExtensionDataObject)
{
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:4,代码来源:XmlObjectSerializerReadContextComplex.cs
示例16: CreateXmlContent
public static XmlSyndicationContent CreateXmlContent(object dataContractObject, XmlObjectSerializer dataContractSerializer)
{
return new XmlSyndicationContent(Atom10Constants.XmlMediaType, dataContractObject, dataContractSerializer);
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:4,代码来源:SyndicationContent.cs
示例17: SerializeClaim
public static void SerializeClaim(Claim claim, SctClaimDictionary dictionary, XmlDictionaryWriter writer, XmlObjectSerializer serializer)
{
// the order in which known claim types are checked is optimized for use patterns
if (claim == null)
{
writer.WriteElementString(dictionary.NullValue, dictionary.EmptyString, string.Empty);
return;
}
else if (ClaimTypes.Sid.Equals(claim.ClaimType))
{
writer.WriteStartElement(dictionary.WindowsSidClaim, dictionary.EmptyString);
WriteRightAttribute(claim, dictionary, writer);
SerializeSid((SecurityIdentifier)claim.Resource, dictionary, writer);
writer.WriteEndElement();
return;
}
else if (ClaimTypes.DenyOnlySid.Equals(claim.ClaimType))
{
writer.WriteStartElement(dictionary.DenyOnlySidClaim, dictionary.EmptyString);
WriteRightAttribute(claim, dictionary, writer);
SerializeSid((SecurityIdentifier)claim.Resource, dictionary, writer);
writer.WriteEndElement();
return;
}
else if (ClaimTypes.X500DistinguishedName.Equals(claim.ClaimType))
{
writer.WriteStartElement(dictionary.X500DistinguishedNameClaim, dictionary.EmptyString);
WriteRightAttribute(claim, dictionary, writer);
byte[] rawData = ((X500DistinguishedName)claim.Resource).RawData;
writer.WriteBase64(rawData, 0, rawData.Length);
writer.WriteEndElement();
return;
}
else if (ClaimTypes.Thumbprint.Equals(claim.ClaimType))
{
writer.WriteStartElement(dictionary.X509ThumbprintClaim, dictionary.EmptyString);
WriteRightAttribute(claim, dictionary, writer);
byte[] thumbprint = (byte[])claim.Resource;
writer.WriteBase64(thumbprint, 0, thumbprint.Length);
writer.WriteEndElement();
return;
}
else if (ClaimTypes.Name.Equals(claim.ClaimType))
{
writer.WriteStartElement(dictionary.NameClaim, dictionary.EmptyString);
WriteRightAttribute(claim, dictionary, writer);
writer.WriteString((string)claim.Resource);
writer.WriteEndElement();
return;
}
else if (ClaimTypes.Dns.Equals(claim.ClaimType))
{
writer.WriteStartElement(dictionary.DnsClaim, dictionary.EmptyString);
WriteRightAttribute(claim, dictionary, writer);
writer.WriteString((string)claim.Resource);
writer.WriteEndElement();
return;
}
else if (ClaimTypes.Rsa.Equals(claim.ClaimType))
{
writer.WriteStartElement(dictionary.RsaClaim, dictionary.EmptyString);
WriteRightAttribute(claim, dictionary, writer);
writer.WriteString(((RSA)claim.Resource).ToXmlString(false));
writer.WriteEndElement();
return;
}
else if (ClaimTypes.Email.Equals(claim.ClaimType))
{
writer.WriteStartElement(dictionary.MailAddressClaim, dictionary.EmptyString);
WriteRightAttribute(claim, dictionary, writer);
writer.WriteString(((MailAddress)claim.Resource).Address);
writer.WriteEndElement();
return;
}
else if (claim == Claim.System)
{
writer.WriteElementString(dictionary.SystemClaim, dictionary.EmptyString, string.Empty);
return;
}
else if (ClaimTypes.Hash.Equals(claim.ClaimType))
{
writer.WriteStartElement(dictionary.HashClaim, dictionary.EmptyString);
WriteRightAttribute(claim, dictionary, writer);
byte[] hash = (byte[])claim.Resource;
writer.WriteBase64(hash, 0, hash.Length);
writer.WriteEndElement();
return;
}
else if (ClaimTypes.Spn.Equals(claim.ClaimType))
{
writer.WriteStartElement(dictionary.SpnClaim, dictionary.EmptyString);
WriteRightAttribute(claim, dictionary, writer);
writer.WriteString((string)claim.Resource);
writer.WriteEndElement();
return;
}
else if (ClaimTypes.Upn.Equals(claim.ClaimType))
{
writer.WriteStartElement(dictionary.UpnClaim, dictionary.EmptyString);
WriteRightAttribute(claim, dictionary, writer);
//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:SctClaimSerializer.cs
示例18: DeserializePrimaryIdentity
static IIdentity DeserializePrimaryIdentity(XmlDictionaryReader reader, SctClaimDictionary dictionary, XmlObjectSerializer serializer)
{
IIdentity identity = null;
if (reader.IsStartElement(dictionary.PrimaryIdentity, dictionary.EmptyString))
{
reader.ReadStartElement();
if (reader.IsStartElement(dictionary.WindowsSidIdentity, dictionary.EmptyString))
{
SecurityIdentifier sid = ReadSidAttribute(reader, dictionary);
string authenticationType = reader.GetAttribute(dictionary.AuthenticationType, dictionary.EmptyString);
reader.ReadStartElement();
string name = reader.ReadContentAsString();
identity = new WindowsSidIdentity(sid, name, authenticationType ?? String.Empty);
reader.ReadEndElement();
}
else if (reader.IsStartElement(dictionary.GenericIdentity, dictionary.EmptyString))
{
string authenticationType = reader.GetAttribute(dictionary.AuthenticationType, dictionary.EmptyString);
reader.ReadStartElement();
string name = reader.ReadContentAsString();
identity = SecurityUtils.CreateIdentity(name, authenticationType ?? String.Empty);
reader.ReadEndElement();
}
else
{
identity = (IIdentity)serializer.ReadObject(reader);
}
reader.ReadEndElement();
}
return identity;
}
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:31,代码来源:SctClaimSerializer.cs
示例19: DeserializeClaim
public static Claim DeserializeClaim(XmlDictionaryReader reader, SctClaimDictionary dictionary, XmlObjectSerializer serializer)
{
if (reader.IsStartElement(dictionary.NullValue, dictionary.EmptyString))
{
reader.ReadElementString();
return null;
}
else if (reader.IsStartElement(dictionary.WindowsSidClaim, dictionary.EmptyString))
{
string right = ReadRightAttribute(reader, dictionary);
reader.ReadStartElement();
byte[] sidBytes = reader.ReadContentAsBase64();
reader.ReadEndElement();
return new Claim(ClaimTypes.Sid, new SecurityIdentifier(sidBytes, 0), right);
}
else if (reader.IsStartElement(dictionary.DenyOnlySidClaim, dictionary.EmptyString))
{
string right = ReadRightAttribute(reader, dictionary);
reader.ReadStartElement();
byte[] sidBytes = reader.ReadContentAsBase64();
reader.ReadEndElement();
return new Claim(ClaimTypes.DenyOnlySid, new SecurityIdentifier(sidBytes, 0), right);
}
else if (reader.IsStartElement(dictionary.X500DistinguishedNameClaim, dictionary.EmptyString))
{
string right = ReadRightAttribute(reader, dictionary);
reader.ReadStartElement();
byte[] rawData = reader.ReadContentAsBase64();
reader.ReadEndElement();
return new Claim(ClaimTypes.X500DistinguishedName, new X500DistinguishedName(rawData), right);
}
else if (reader.IsStartElement(dictionary.X509ThumbprintClaim, dictionary.EmptyString))
{
string right = ReadRightAttribute(reader, dictionary);
reader.ReadStartElement();
byte[] thumbprint = reader.ReadContentAsBase64();
reader.ReadEndElement();
return new Claim(ClaimTypes.Thumbprint, thumbprint, right);
}
else if (reader.IsStartElement(dictionary.NameClaim, dictionary.EmptyString))
{
string right = ReadRightAttribute(reader, dictionary);
reader.ReadStartElement();
string name = reader.ReadString();
reader.ReadEndElement();
return new Claim(ClaimTypes.Name, name, right);
}
else if (reader.IsStartElement(dictionary.DnsClaim, dictionary.EmptyString))
{
string right = ReadRightAttribute(reader, dictionary);
reader.ReadStartElement();
string dns = reader.ReadString();
reader.ReadEndElement();
return new Claim(ClaimTypes.Dns, dns, right);
}
else if (reader.IsStartElement(dictionary.RsaClaim, dictionary.EmptyString))
{
string right = ReadRightAttribute(reader, dictionary);
reader.ReadStartElement();
string rsaXml = reader.ReadString();
reader.ReadEndElement();
System.Security.Cryptography.RSACryptoServiceProvider rsa = new System.Security.Cryptography.RSACryptoServiceProvider();
rsa.FromXmlString(rsaXml);
return new Claim(ClaimTypes.Rsa, rsa, right);
}
else if (reader.IsStartElement(dictionary.MailAddressClaim, dictionary.EmptyString))
{
string right = ReadRightAttribute(reader, dictionary);
reader.ReadStartElement();
string address = reader.ReadString();
reader.ReadEndElement();
return new Claim(ClaimTypes.Email, new System.Net.Mail.MailAddress(address), right);
}
else if (reader.IsStartElement(dictionary.SystemClaim, dictionary.EmptyString))
{
reader.ReadElementString();
return Claim.System;
}
else if (reader.IsStartElement(dictionary.HashClaim, dictionary.EmptyString))
{
string right = ReadRightAttribute(reader, dictionary);
reader.ReadStartElement();
byte[] hash = reader.ReadContentAsBase64();
reader.ReadEndElement();
return new Claim(ClaimTypes.Hash, hash, right);
}
else if (reader.IsStartElement(dictionary.SpnClaim, dictionary.EmptyString))
{
string right = ReadRightAttribute(reader, dictionary);
reader.ReadStartElement();
string spn = reader.ReadString();
reader.ReadEndElement();
return new Claim(ClaimTypes.Spn, spn, right);
}
else if (reader.IsStartElement(dictionary.UpnClaim, dictionary.EmptyString))
{
string right = ReadRightAttribute(reader, dictionary);
reader.ReadStartElement();
string upn = reader.ReadString();
//.........这里部分代码省略.........
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:SctClaimSerializer.cs
示例20: DefaultMessageHeader
internal DefaultMessageHeader (string name, string ns, object value, XmlObjectSerializer formatter,
bool isReferenceParameter,
bool mustUnderstand, string actor, bool relay)
{
this.name = name;
this.ns = ns;
this.value = value;
this.formatter = formatter;
this.is_ref = isReferenceParameter;
this.must_understand = mustUnderstand;
this.actor = actor;
this.relay = relay;
}
开发者ID:kumpera,项目名称:mono,代码行数:13,代码来源:MessageHeader.cs
注:本文中的System.Runtime.Serialization.XmlObjectSerializer类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论