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


C# XmlDictionaryReader.ReadFullStartElement方法代码示例

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


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

示例1: GetReaderAtDetailContents11

 public static XmlDictionaryReader GetReaderAtDetailContents11(string detailName, string detailNamespace, XmlDictionaryReader headerReader)
 {
     XmlDictionaryString namespaceUri = DXD.Wsrm11Dictionary.Namespace;
     headerReader.ReadFullStartElement(XD.WsrmFeb2005Dictionary.SequenceFault, namespaceUri);
     headerReader.Skip();
     headerReader.ReadFullStartElement(XD.Message12Dictionary.FaultDetail, namespaceUri);
     if (((headerReader.NodeType == XmlNodeType.Element) && !(headerReader.NamespaceURI != detailNamespace)) && !(headerReader.LocalName != detailName))
     {
         return headerReader;
     }
     headerReader.Close();
     return null;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:13,代码来源:WsrmSequenceFaultHeader.cs

示例2: Deserialize

		public static void Deserialize(XmlDictionaryReader reader, out IList<DirectoryControl> controls, bool mustBePresent, bool fullChecks)
		{
			string str = null;
			string str1 = null;
			bool flag;
			byte[] numArray = null;
			controls = new List<DirectoryControl>();
			if (mustBePresent || reader.IsStartElement("controls", "http://schemas.microsoft.com/2008/1/ActiveDirectory"))
			{
				reader.ReadFullStartElement("controls", "http://schemas.microsoft.com/2008/1/ActiveDirectory");
				while (reader.IsStartElement("control", "http://schemas.microsoft.com/2008/1/ActiveDirectory"))
				{
					string attribute = reader.GetAttribute("type");
					string attribute1 = reader.GetAttribute("criticality");
					reader.Read();
					if (!reader.IsStartElement("controlValue", "http://schemas.microsoft.com/2008/1/ActiveDirectory"))
					{
						numArray = null;
					}
					else
					{
						string attribute2 = reader.GetAttribute("type", "http://www.w3.org/2001/XMLSchema-instance");
						if (attribute2 != null)
						{
							XmlUtility.SplitPrefix(attribute2, out str, out str1);
							numArray = reader.ReadElementContentAsBase64();
						}
						else
						{
							throw new ArgumentException();
						}
					}
					if (!string.Equals("true", attribute1))
					{
						flag = false;
					}
					else
					{
						flag = true;
					}
					DirectoryControl directoryControl = new DirectoryControl(attribute, numArray, flag, true);
					controls.Add(directoryControl);
					reader.Read();
				}
				return;
			}
			else
			{
				return;
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:51,代码来源:DirectoryControlSerializer.cs

示例3: GetReaderAtDetailContentsFeb2005

 public static XmlDictionaryReader GetReaderAtDetailContentsFeb2005(string detailName, string detailNamespace, XmlDictionaryReader headerReader)
 {
     XmlDictionaryReader reader;
     try
     {
         WsrmFeb2005Dictionary dictionary = XD.WsrmFeb2005Dictionary;
         XmlDictionaryString namespaceUri = dictionary.Namespace;
         XmlBuffer buffer = null;
         int sectionIndex = 0;
         int depth = headerReader.Depth;
         headerReader.ReadFullStartElement(dictionary.SequenceFault, namespaceUri);
         while (headerReader.Depth > depth)
         {
             if (((headerReader.NodeType == XmlNodeType.Element) && (headerReader.NamespaceURI == detailNamespace)) && (headerReader.LocalName == detailName))
             {
                 if (buffer != null)
                 {
                     return null;
                 }
                 buffer = new XmlBuffer(0x7fffffff);
                 try
                 {
                     sectionIndex = buffer.SectionCount;
                     buffer.OpenSection(headerReader.Quotas).WriteNode(headerReader, false);
                     continue;
                 }
                 finally
                 {
                     buffer.CloseSection();
                 }
             }
             if (headerReader.Depth == depth)
             {
                 break;
             }
             headerReader.Read();
         }
         if (buffer == null)
         {
             return null;
         }
         buffer.Close();
         reader = buffer.GetReader(sectionIndex);
     }
     finally
     {
         headerReader.Close();
     }
     return reader;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:50,代码来源:WsrmSequenceFaultHeader.cs

示例4: ReadFrom

 private void ReadFrom(XmlDictionaryReader reader)
 {
     try
     {
         reader.ReadFullStartElement(this.coordinationXmlDictionaryStrings.RegisterResponse, this.coordinationXmlDictionaryStrings.Namespace);
         this.CoordinatorProtocolService = EndpointAddress.ReadFrom(MessagingVersionHelper.AddressingVersion(this.protocolVersion), reader, this.coordinationXmlDictionaryStrings.CoordinatorProtocolService, this.coordinationXmlDictionaryStrings.Namespace);
         while (reader.IsStartElement())
         {
             reader.Skip();
         }
         reader.ReadEndElement();
     }
     catch (XmlException exception)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidMessageException(Microsoft.Transactions.SR.GetString("InvalidMessageBody"), exception));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:17,代码来源:RegisterResponse.cs

示例5: ReadFrom

 private void ReadFrom(XmlDictionaryReader reader)
 {
     try
     {
         reader.ReadFullStartElement(this.coordinationXmlDictionaryStrings.CreateCoordinationContextResponse, this.coordinationXmlDictionaryStrings.Namespace);
         this.CoordinationContext = Microsoft.Transactions.Wsat.Messaging.CoordinationContext.ReadFrom(reader, this.coordinationXmlDictionaryStrings.CoordinationContext, this.coordinationXmlDictionaryStrings.Namespace, this.protocolVersion);
         while (reader.IsStartElement())
         {
             reader.Skip();
         }
         reader.ReadEndElement();
     }
     catch (XmlException exception)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidMessageException(Microsoft.Transactions.SR.GetString("InvalidMessageBody"), exception));
     }
     catch (InvalidCoordinationContextException exception2)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidMessageException(Microsoft.Transactions.SR.GetString("InvalidMessageBody"), exception2));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:21,代码来源:CreateCoordinationContextResponse.cs

示例6: ReadFrom

        public static EndpointAddress ReadFrom(AddressingVersion addressingVersion, XmlDictionaryReader reader)
        {
            if (reader == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
            if (addressingVersion == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("addressingVersion");

            reader.ReadFullStartElement();
            EndpointAddress ea = ReadFromDriver(addressingVersion, reader);
            reader.ReadEndElement();
            return ea;
        }
开发者ID:uQr,项目名称:referencesource,代码行数:12,代码来源:EndpointAddress.cs

示例7: ReadFrom

 private static OleTxTransactionHeader ReadFrom(XmlDictionaryReader reader)
 {
     System.ServiceModel.Transactions.WsatExtendedInformation wsatInfo = null;
     if (reader.IsStartElement(XD.OleTxTransactionExternalDictionary.OleTxTransaction, XD.OleTxTransactionExternalDictionary.Namespace))
     {
         Uri uri;
         string attribute = reader.GetAttribute(XD.CoordinationExternalDictionary.Identifier, CoordinationNamespace);
         if (!string.IsNullOrEmpty(attribute) && !Uri.TryCreate(attribute, UriKind.Absolute, out uri))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidWsatExtendedInfo")));
         }
         string str2 = reader.GetAttribute(XD.CoordinationExternalDictionary.Expires, CoordinationNamespace);
         uint timeout = 0;
         if (!string.IsNullOrEmpty(str2))
         {
             try
             {
                 timeout = XmlConvert.ToUInt32(str2);
             }
             catch (FormatException exception)
             {
                 DiagnosticUtility.ExceptionUtility.TraceHandledException(exception, TraceEventType.Error);
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidWsatExtendedInfo"), exception));
             }
             catch (OverflowException exception2)
             {
                 DiagnosticUtility.ExceptionUtility.TraceHandledException(exception2, TraceEventType.Error);
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidWsatExtendedInfo"), exception2));
             }
         }
         if (!string.IsNullOrEmpty(attribute) || (timeout != 0))
         {
             wsatInfo = new System.ServiceModel.Transactions.WsatExtendedInformation(attribute, timeout);
         }
     }
     reader.ReadFullStartElement(XD.OleTxTransactionExternalDictionary.OleTxTransaction, XD.OleTxTransactionExternalDictionary.Namespace);
     byte[] propagationToken = ReadPropagationTokenElement(reader);
     while (reader.IsStartElement())
     {
         reader.Skip();
     }
     reader.ReadEndElement();
     return new OleTxTransactionHeader(propagationToken, wsatInfo);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:44,代码来源:OleTxTransactionHeader.cs

示例8: ReadPropagationTokenElement

 public static byte[] ReadPropagationTokenElement(XmlDictionaryReader reader)
 {
     reader.ReadFullStartElement(XD.OleTxTransactionExternalDictionary.PropagationToken, XD.OleTxTransactionExternalDictionary.Namespace);
     byte[] buffer = reader.ReadContentAsBase64();
     if (buffer.Length == 0)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidPropagationToken")));
     }
     reader.ReadEndElement();
     return buffer;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:11,代码来源:OleTxTransactionHeader.cs

示例9: ReadClaimProperties

        /// <summary>
        /// Reads ClaimProperties from a XmlDictionaryReader and adds them to a Dictionary.
        /// </summary>
        /// <param name="dictionaryReader">XmlDictionaryReader positioned at the element dictionary.ClaimProperties </param>
        /// <param name="dictionary">SessionDictionary to provide dictionary strings.</param>
        /// <param name="properties">Dictionary to add properties to.</param>
        /// <exception cref="ArgumentNullException">The input argument 'dictionaryReader',  'dictionary' or 'properties' is null.</exception>
        /// <exception cref="SecurityTokenException">Is thrown if the 'name' of a property is null or an empty string.</exception>
        /// <exception cref="SecurityTokenException">Is thrown if the 'value' of a property is null.</exception>
        /// <remarks>Reads 'n' properties.</remarks>
        void ReadClaimProperties(XmlDictionaryReader dictionaryReader, SessionDictionary dictionary, IDictionary<string, string> properties)
        {
            if (dictionaryReader == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dictionaryReader");
            }

            if (dictionary == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dictionary");
            }

            if (properties == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("properties");
            }

            dictionaryReader.ReadStartElement();

            // <Property>
            while (dictionaryReader.IsStartElement(dictionary.ClaimProperty, dictionary.EmptyString))
            {
                // @Name, @Value

                string name = dictionaryReader.GetAttribute(dictionary.ClaimPropertyName, dictionary.EmptyString);
                string value = dictionaryReader.GetAttribute(dictionary.ClaimPropertyValue, dictionary.EmptyString);

                if (string.IsNullOrEmpty(name))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.ID4249)));
                }

                if (string.IsNullOrEmpty(value))
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.ID4250)));
                }

                properties.Add(new KeyValuePair<string, string>(name, value));

                dictionaryReader.ReadFullStartElement();
                dictionaryReader.ReadEndElement();
            }

            dictionaryReader.ReadEndElement();
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:55,代码来源:SessionSecurityToken.cs

示例10: ReadFrom

 private static WsatRegistrationHeader ReadFrom(XmlDictionaryReader reader)
 {
     string str;
     string str2;
     reader.ReadFullStartElement(XD.DotNetAtomicTransactionExternalDictionary.RegisterInfo, XD.DotNetAtomicTransactionExternalDictionary.Namespace);
     reader.MoveToStartElement(XD.DotNetAtomicTransactionExternalDictionary.LocalTransactionId, XD.DotNetAtomicTransactionExternalDictionary.Namespace);
     Guid transactionId = reader.ReadElementContentAsGuid();
     if (transactionId == Guid.Empty)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidRegistrationHeaderTransactionId")));
     }
     if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.ContextId, XD.DotNetAtomicTransactionExternalDictionary.Namespace))
     {
         Uri uri;
         str = reader.ReadElementContentAsString().Trim();
         if (((str.Length == 0) || (str.Length > 0x100)) || !Uri.TryCreate(str, UriKind.Absolute, out uri))
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidRegistrationHeaderIdentifier")));
         }
     }
     else
     {
         str = null;
     }
     if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.TokenId, XD.DotNetAtomicTransactionExternalDictionary.Namespace))
     {
         str2 = reader.ReadElementContentAsString().Trim();
         if (str2.Length == 0)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidRegistrationHeaderTokenId")));
         }
     }
     else
     {
         str2 = null;
     }
     while (reader.IsStartElement())
     {
         reader.Skip();
     }
     reader.ReadEndElement();
     return new WsatRegistrationHeader(transactionId, str, str2);
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:43,代码来源:WsatRegistrationHeader.cs

示例11: ReadFrom

 public static EndpointAddress ReadFrom(AddressingVersion addressingVersion, XmlDictionaryReader reader, XmlDictionaryString localName, XmlDictionaryString ns)
 {
     if (reader == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");
     }
     if (addressingVersion == null)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("addressingVersion");
     }
     reader.ReadFullStartElement(localName, ns);
     EndpointAddress address = ReadFromDriver(addressingVersion, reader);
     reader.ReadEndElement();
     return address;
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:15,代码来源:EndpointAddress.cs

示例12: ReadFrom

        static OleTxTransactionHeader ReadFrom(XmlDictionaryReader reader)
        {
            WsatExtendedInformation info = null;

            if (reader.IsStartElement(XD.OleTxTransactionExternalDictionary.OleTxTransaction,
                                      XD.OleTxTransactionExternalDictionary.Namespace))
            {
                string identifier = reader.GetAttribute(XD.CoordinationExternalDictionary.Identifier, CoordinationNamespace);

                if (!string.IsNullOrEmpty(identifier))
                {
                    // Verify identifier is really a URI
                    Uri uri;
                    if (!Uri.TryCreate(identifier, UriKind.Absolute, out uri))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.InvalidWsatExtendedInfo)));
                    }
                }

                string attr = reader.GetAttribute(XD.CoordinationExternalDictionary.Expires, CoordinationNamespace);

                uint timeout = 0;
                if (!string.IsNullOrEmpty(attr))
                {
                    try
                    {
                        timeout = XmlConvert.ToUInt32(attr);
                    }
                    catch (FormatException e)
                    {
                        DiagnosticUtility.TraceHandledException(e, TraceEventType.Error);
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.InvalidWsatExtendedInfo), e));
                    }
                    catch (OverflowException e)
                    {
                        DiagnosticUtility.TraceHandledException(e, TraceEventType.Error);
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.GetString(SR.InvalidWsatExtendedInfo), e));
                    }
                }

                if (!string.IsNullOrEmpty(identifier) || timeout != 0)
                {
                    info = new WsatExtendedInformation(identifier, timeout);
                }
            }

            reader.ReadFullStartElement(XD.OleTxTransactionExternalDictionary.OleTxTransaction,
                                        XD.OleTxTransactionExternalDictionary.Namespace);

            byte[] propagationToken = ReadPropagationTokenElement(reader);

            // Skip extensibility elements...
            while (reader.IsStartElement())
            {
                reader.Skip();
            }
            reader.ReadEndElement();

            return new OleTxTransactionHeader(propagationToken, info);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:60,代码来源:OletxTransactionHeader.cs

示例13: ReadFrom

 private void ReadFrom(XmlDictionaryReader reader)
 {
     try
     {
         reader.ReadFullStartElement(this.coordinationXmlDictionaryStrings.Register, this.coordinationXmlDictionaryStrings.Namespace);
         reader.MoveToStartElement(this.coordinationXmlDictionaryStrings.Protocol, this.coordinationXmlDictionaryStrings.Namespace);
         this.Protocol = WSAtomicTransactionStrings.WellKnownNameToProtocol(reader.ReadElementContentAsString().Trim(), this.protocolVersion);
         if (this.Protocol == ControlProtocol.None)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidMessageException(Microsoft.Transactions.SR.GetString("InvalidMessageBody")));
         }
         this.ParticipantProtocolService = EndpointAddress.ReadFrom(MessagingVersionHelper.AddressingVersion(this.protocolVersion), reader, this.coordinationXmlDictionaryStrings.ParticipantProtocolService, this.coordinationXmlDictionaryStrings.Namespace);
         if (reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.Loopback, XD.DotNetAtomicTransactionExternalDictionary.Namespace))
         {
             this.Loopback = reader.ReadElementContentAsGuid();
         }
         while (reader.IsStartElement())
         {
             reader.Skip();
         }
         reader.ReadEndElement();
     }
     catch (XmlException exception)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidMessageException(Microsoft.Transactions.SR.GetString("InvalidMessageBody"), exception));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:27,代码来源:Register.cs

示例14: ReadFrom

 private void ReadFrom(XmlDictionaryReader reader)
 {
     try
     {
         reader.ReadFullStartElement(this.coordinationXmlDictionaryStrings.CreateCoordinationContext, this.coordinationXmlDictionaryStrings.Namespace);
         if (reader.IsStartElement(this.coordinationXmlDictionaryStrings.Expires, this.coordinationXmlDictionaryStrings.Namespace))
         {
             int num = reader.ReadElementContentAsInt();
             if (num < 0)
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidMessageException(Microsoft.Transactions.SR.GetString("InvalidMessageBody")));
             }
             this.expiration = (uint) num;
             this.expiresPresent = true;
         }
         if (reader.IsStartElement(this.coordinationXmlDictionaryStrings.CurrentContext, this.coordinationXmlDictionaryStrings.Namespace))
         {
             this.CurrentContext = CoordinationContext.ReadFrom(reader, this.coordinationXmlDictionaryStrings.CurrentContext, this.coordinationXmlDictionaryStrings.Namespace, this.protocolVersion);
         }
         reader.MoveToStartElement(this.coordinationXmlDictionaryStrings.CoordinationType, this.coordinationXmlDictionaryStrings.Namespace);
         if (reader.ReadElementContentAsString().Trim() != this.atomicTransactionStrings.Namespace)
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidMessageException(Microsoft.Transactions.SR.GetString("InvalidMessageBody")));
         }
         if (!reader.IsStartElement(XD.DotNetAtomicTransactionExternalDictionary.IsolationLevel, XD.DotNetAtomicTransactionExternalDictionary.Namespace))
         {
             goto Label_016B;
         }
         this.IsolationLevel = (System.Transactions.IsolationLevel) reader.ReadElementContentAsInt();
         if (((this.IsolationLevel >= System.Transactions.IsolationLevel.Serializable) && (this.IsolationLevel <= System.Transactions.IsolationLevel.Unspecified)) && (this.IsolationLevel != System.Transactions.IsolationLevel.Snapshot))
         {
             goto Label_016B;
         }
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidMessageException(Microsoft.Transactions.SR.GetString("InvalidMessageBody")));
     Label_0165:
         reader.Skip();
     Label_016B:
         if (reader.IsStartElement())
         {
             goto Label_0165;
         }
         reader.ReadEndElement();
     }
     catch (XmlException exception)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidMessageException(Microsoft.Transactions.SR.GetString("InvalidMessageBody"), exception));
     }
     catch (InvalidCoordinationContextException exception2)
     {
         throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidMessageException(Microsoft.Transactions.SR.GetString("InvalidMessageBody"), exception2));
     }
 }
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:52,代码来源:CreateCoordinationContext.cs

示例15: ReadIdentity

        /// <summary>
        /// Reads a single ClaimsIdentity from a XmlDictionaryReader.
        /// </summary>
        /// <param name="dictionaryReader">XmlDictionaryReader positioned at dictionary.Identity.</param>
        /// <param name="dictionary">SessionDictionary to provide dictionary strings.</param>
        /// <exception cref="ArgumentNullException">The input argument 'dictionaryReader' or 'dictionary' is null.</exception>
        /// <exception cref="SecurityTokenException">The dictionaryReader is not positioned a SessionDictionary.Identity.</exception>
        /// <returns>ClaimsIdentity</returns>
        ClaimsIdentity ReadIdentity(XmlDictionaryReader dictionaryReader, SessionDictionary dictionary)
        {
            if (dictionaryReader == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dictionaryReader");
            }

            if (dictionary == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("dictionary");
            }

            dictionaryReader.MoveToContent();

            ClaimsIdentity identity = null;

            if (!dictionaryReader.IsStartElement(dictionary.Identity, dictionary.EmptyString))
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.ID3007, dictionaryReader.LocalName, dictionaryReader.NamespaceURI)));
            }

            // @NameClaimType
            string nameClaimType = dictionaryReader.GetAttribute(dictionary.NameClaimType, dictionary.EmptyString);

            // @RoleClaimType
            string roleClaimType = dictionaryReader.GetAttribute(dictionary.RoleClaimType, dictionary.EmptyString);

            // @WindowsLogonName (optional) => windows claims identity
            string logonName = dictionaryReader.GetAttribute(dictionary.WindowsLogonName, dictionary.EmptyString);
            string authenticationType = dictionaryReader.GetAttribute(dictionary.AuthenticationType, dictionary.EmptyString);

            if (string.IsNullOrEmpty(logonName))
            {
                identity = new ClaimsIdentity(authenticationType, nameClaimType, roleClaimType);
            }
            else
            {
                // The WindowsIdentity(string, string) c'tor does not set the Auth type. Hence we use that c'tor to get a intPtr and 
                // call the other c'tor that actually sets the authType passed in. 
                // DevDiv 279196 tracks the issue and in WindowsIdentity c'tor. Its too late to fix it in 4.5 cycle as we are in Beta and would not be
                // able to complete the analysis of the change for the current release. This should be investigated in 5.0
                WindowsIdentity winId = new WindowsIdentity(GetUpn(logonName));
                identity = new WindowsIdentity(winId.Token, authenticationType);
            }

            // @Label
            identity.Label = dictionaryReader.GetAttribute(dictionary.Label, dictionary.EmptyString);


            dictionaryReader.ReadFullStartElement();

            // <ClaimCollection>
            if (dictionaryReader.IsStartElement(dictionary.ClaimCollection, dictionary.EmptyString))
            {
                dictionaryReader.ReadStartElement();

                Collection<Claim> claims = new Collection<Claim>();
                ReadClaims(dictionaryReader, dictionary, claims);
                identity.AddClaims(claims);

                dictionaryReader.ReadEndElement();
            }

            // <Actor>
            if (dictionaryReader.IsStartElement(dictionary.Actor, dictionary.EmptyString))
            {
                dictionaryReader.ReadStartElement();

                identity.Actor = ReadIdentity(dictionaryReader, dictionary);

                dictionaryReader.ReadEndElement();
            }

            if (dictionaryReader.IsStartElement(dictionary.BootstrapToken, dictionary.EmptyString))
            {
                dictionaryReader.ReadStartElement();

                byte[] bytes = dictionaryReader.ReadContentAsBase64();
                using (MemoryStream ms = new MemoryStream(bytes))
                {
                    BinaryFormatter formatter = new BinaryFormatter();
                    identity.BootstrapContext = (BootstrapContext)formatter.Deserialize(ms);
                }

                dictionaryReader.ReadEndElement();
            }

            dictionaryReader.ReadEndElement(); // Identity

            return identity;
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:99,代码来源:SessionSecurityToken.cs


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