当前位置: 首页>>代码示例>>C#>>正文


C# XmlObjectSerializer.ReadObject方法代码示例

本文整理汇总了C#中System.Runtime.Serialization.XmlObjectSerializer.ReadObject方法的典型用法代码示例。如果您正苦于以下问题:C# XmlObjectSerializer.ReadObject方法的具体用法?C# XmlObjectSerializer.ReadObject怎么用?C# XmlObjectSerializer.ReadObject使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Runtime.Serialization.XmlObjectSerializer的用法示例。


在下文中一共展示了XmlObjectSerializer.ReadObject方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: 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

示例2: 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

示例3: 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

示例4: DeserializeClaim


//.........这里部分代码省略.........
            {
                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();
                reader.ReadEndElement();
                return new Claim(ClaimTypes.Upn, upn, right);
            }
            else if (reader.IsStartElement(dictionary.UrlClaim, dictionary.EmptyString))
            {
                string right = ReadRightAttribute(reader, dictionary);
                reader.ReadStartElement();
                string url = reader.ReadString();
                reader.ReadEndElement();
                return new Claim(ClaimTypes.Uri, new Uri(url), right);
            }
            else
            {
                return (Claim)serializer.ReadObject(reader);
            }
        }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:101,代码来源:SctClaimSerializer.cs

示例5: DeserializeClaim


//.........这里部分代码省略.........
         reader.ReadEndElement();
         return new Claim(ClaimTypes.Sid, new SecurityIdentifier(binaryForm, 0), right);
     }
     if (reader.IsStartElement(dictionary.DenyOnlySidClaim, dictionary.EmptyString))
     {
         string str2 = ReadRightAttribute(reader, dictionary);
         reader.ReadStartElement();
         byte[] buffer2 = reader.ReadContentAsBase64();
         reader.ReadEndElement();
         return new Claim(ClaimTypes.DenyOnlySid, new SecurityIdentifier(buffer2, 0), str2);
     }
     if (reader.IsStartElement(dictionary.X500DistinguishedNameClaim, dictionary.EmptyString))
     {
         string str3 = ReadRightAttribute(reader, dictionary);
         reader.ReadStartElement();
         byte[] encodedDistinguishedName = reader.ReadContentAsBase64();
         reader.ReadEndElement();
         return new Claim(ClaimTypes.X500DistinguishedName, new X500DistinguishedName(encodedDistinguishedName), str3);
     }
     if (reader.IsStartElement(dictionary.X509ThumbprintClaim, dictionary.EmptyString))
     {
         string str4 = ReadRightAttribute(reader, dictionary);
         reader.ReadStartElement();
         byte[] resource = reader.ReadContentAsBase64();
         reader.ReadEndElement();
         return new Claim(ClaimTypes.Thumbprint, resource, str4);
     }
     if (reader.IsStartElement(dictionary.NameClaim, dictionary.EmptyString))
     {
         string str5 = ReadRightAttribute(reader, dictionary);
         reader.ReadStartElement();
         string str6 = reader.ReadString();
         reader.ReadEndElement();
         return new Claim(ClaimTypes.Name, str6, str5);
     }
     if (reader.IsStartElement(dictionary.DnsClaim, dictionary.EmptyString))
     {
         string str7 = ReadRightAttribute(reader, dictionary);
         reader.ReadStartElement();
         string str8 = reader.ReadString();
         reader.ReadEndElement();
         return new Claim(ClaimTypes.Dns, str8, str7);
     }
     if (reader.IsStartElement(dictionary.RsaClaim, dictionary.EmptyString))
     {
         string str9 = ReadRightAttribute(reader, dictionary);
         reader.ReadStartElement();
         string xmlString = reader.ReadString();
         reader.ReadEndElement();
         RSACryptoServiceProvider provider = new RSACryptoServiceProvider();
         provider.FromXmlString(xmlString);
         return new Claim(ClaimTypes.Rsa, provider, str9);
     }
     if (reader.IsStartElement(dictionary.MailAddressClaim, dictionary.EmptyString))
     {
         string str11 = ReadRightAttribute(reader, dictionary);
         reader.ReadStartElement();
         string address = reader.ReadString();
         reader.ReadEndElement();
         return new Claim(ClaimTypes.Email, new MailAddress(address), str11);
     }
     if (reader.IsStartElement(dictionary.SystemClaim, dictionary.EmptyString))
     {
         reader.ReadElementString();
         return Claim.System;
     }
     if (reader.IsStartElement(dictionary.HashClaim, dictionary.EmptyString))
     {
         string str13 = ReadRightAttribute(reader, dictionary);
         reader.ReadStartElement();
         byte[] buffer5 = reader.ReadContentAsBase64();
         reader.ReadEndElement();
         return new Claim(ClaimTypes.Hash, buffer5, str13);
     }
     if (reader.IsStartElement(dictionary.SpnClaim, dictionary.EmptyString))
     {
         string str14 = ReadRightAttribute(reader, dictionary);
         reader.ReadStartElement();
         string str15 = reader.ReadString();
         reader.ReadEndElement();
         return new Claim(ClaimTypes.Spn, str15, str14);
     }
     if (reader.IsStartElement(dictionary.UpnClaim, dictionary.EmptyString))
     {
         string str16 = ReadRightAttribute(reader, dictionary);
         reader.ReadStartElement();
         string str17 = reader.ReadString();
         reader.ReadEndElement();
         return new Claim(ClaimTypes.Upn, str17, str16);
     }
     if (reader.IsStartElement(dictionary.UrlClaim, dictionary.EmptyString))
     {
         string str18 = ReadRightAttribute(reader, dictionary);
         reader.ReadStartElement();
         string uriString = reader.ReadString();
         reader.ReadEndElement();
         return new Claim(ClaimTypes.Uri, new Uri(uriString), str18);
     }
     return (Claim) serializer.ReadObject(reader);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:SctClaimSerializer.cs

示例6: LoadFromStream

 /// <summary>
 /// </summary>
 /// <param name="inputStream">
 /// The input stream.
 /// </param>
 /// <param name="serializer">
 /// The serializer.
 /// </param>
 /// <returns>
 /// The load from stream.
 /// </returns>
 protected virtual object LoadFromStream(Stream inputStream, XmlObjectSerializer serializer)
 {
     return serializer.ReadObject(inputStream);
 }
开发者ID:IcodeNet,项目名称:cleansolution,代码行数:15,代码来源:SerializationProvider.cs


注:本文中的System.Runtime.Serialization.XmlObjectSerializer.ReadObject方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。