ReadContentAsString() public méthode

public ReadContentAsString ( ) : string
Résultat string
        internal X509CertificateEndpointIdentity(XmlDictionaryReader reader)
        {
            if (reader == null)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("reader");

            reader.MoveToContent();
            if (reader.IsEmptyElement)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.UnexpectedEmptyElementExpectingClaim, XD.AddressingDictionary.X509v3Certificate.Value, XD.AddressingDictionary.IdentityExtensionNamespace.Value)));

            reader.ReadStartElement(XD.XmlSignatureDictionary.X509Data, XD.XmlSignatureDictionary.Namespace);
            while (reader.IsStartElement(XD.XmlSignatureDictionary.X509Certificate, XD.XmlSignatureDictionary.Namespace))
            {
                reader.MoveToContent();
                X509Certificate2 certificate = new X509Certificate2(Convert.FromBase64String(reader.ReadContentAsString()));
                if (certificateCollection.Count == 0)
                {
                    // This is the first certificate. We assume this as the primary 
                    // certificate and initialize the base class.
                    Initialize(new Claim(ClaimTypes.Thumbprint, certificate.GetCertHash(), Rights.PossessProperty));
                }

                certificateCollection.Add(certificate);
            }

            reader.ReadEndElement();

            if (certificateCollection.Count == 0)
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(SR.Format(SR.UnexpectedEmptyElementExpectingClaim, XD.AddressingDictionary.X509v3Certificate.Value, XD.AddressingDictionary.IdentityExtensionNamespace.Value)));
        }
        private static object DeserializeStruct(XmlDictionaryReader reader, Type targetType)
        {
            if (targetType.IsDefined(typeof(DataContractAttribute), false))
            {
                Dictionary<string, MemberInfo> dataMembers = GetDataMembers(targetType);
                object targetObject = Activator.CreateInstance(targetType);

                reader.ReadStartElement(XmlRpcProtocol.Struct);
                
                while( reader.NodeType != XmlNodeType.EndElement )
                {
                    string memberName;

                    reader.ReadStartElement(XmlRpcProtocol.Member);
                    reader.ReadStartElement(XmlRpcProtocol.Name);
                    memberName = reader.ReadContentAsString();
                    reader.ReadEndElement();
                    
                    reader.ReadStartElement(XmlRpcProtocol.Value);
                    reader.MoveToContent();
                    if (dataMembers.ContainsKey(memberName))
                    {
                        MemberInfo member = dataMembers[memberName];
                        if (member is PropertyInfo)
                        {
                            ((PropertyInfo)member).SetValue(
                                targetObject, 
                                Deserialize(reader, ((PropertyInfo)member).PropertyType), 
                                BindingFlags.Instance | BindingFlags.SetProperty | BindingFlags.Public | BindingFlags.NonPublic, 
                                null, null,
                                CultureInfo.CurrentCulture);
                        }
                        else if (member is FieldInfo)
                        {
                            ((FieldInfo)member).SetValue(
                                targetObject,
                                Deserialize(reader, ((FieldInfo)member).FieldType),
                                BindingFlags.Instance|BindingFlags.SetField|BindingFlags.Public|BindingFlags.NonPublic,
                                null,
                                CultureInfo.CurrentCulture);
                        }
                    }
                    reader.ReadEndElement(); // value
                    reader.ReadEndElement(); // member
                }
                reader.ReadEndElement(); // struct
                reader.MoveToContent();
                return targetObject;                
            }
            else
            {
                throw new InvalidOperationException();
            }
            
        }
		/// <summary>
		/// Reads JSON as a flat dictionary into a message.
		/// </summary>
		/// <param name="messageDictionary">The message dictionary to fill with the JSON-deserialized data.</param>
		/// <param name="reader">The JSON reader.</param>
		internal static void DeserializeJsonAsFlatDictionary(IDictionary<string, string> messageDictionary, XmlDictionaryReader reader) {
			Requires.NotNull(messageDictionary, "messageDictionary");
			Requires.NotNull(reader, "reader");

			reader.Read(); // one extra one to skip the root node.
			while (reader.Read()) {
				if (reader.NodeType == XmlNodeType.EndElement) {
					// This is likely the closing </root> tag.
					continue;
				}

				string key = reader.Name;
				reader.Read();
				string value = reader.ReadContentAsString();
				messageDictionary[key] = value;
			}
		}
 public MessageNumberRolloverFault(FaultCode code, FaultReason reason, XmlDictionaryReader detailReader, ReliableMessagingVersion reliableMessagingVersion) : base(code, "MessageNumberRollover", reason, true, true)
 {
     try
     {
         base.SequenceID = WsrmUtilities.ReadIdentifier(detailReader, reliableMessagingVersion);
         if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
         {
             ulong num;
             detailReader.ReadStartElement(DXD.Wsrm11Dictionary.MaxMessageNumber, WsrmIndex.GetNamespace(reliableMessagingVersion));
             if (!ulong.TryParse(detailReader.ReadContentAsString(), out num) || (num <= 0L))
             {
                 throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(System.ServiceModel.SR.GetString("InvalidSequenceNumber", new object[] { num })));
             }
             detailReader.ReadEndElement();
         }
     }
     finally
     {
         detailReader.Close();
     }
 }
        public MessageNumberRolloverFault(FaultCode code, FaultReason reason, XmlDictionaryReader detailReader,
            ReliableMessagingVersion reliableMessagingVersion)
            : base(code, WsrmFeb2005Strings.MessageNumberRollover, reason, true, true)
        {
            try
            {
                this.SequenceID = WsrmUtilities.ReadIdentifier(detailReader, reliableMessagingVersion);

                if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
                {
                    detailReader.ReadStartElement(DXD.Wsrm11Dictionary.MaxMessageNumber,
                        WsrmIndex.GetNamespace(reliableMessagingVersion));

                    string maxMessageNumberString = detailReader.ReadContentAsString();
                    ulong maxMessageNumber;
                    if (!UInt64.TryParse(maxMessageNumberString, out maxMessageNumber)
                        || (maxMessageNumber <= 0))
                    {
                        throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new XmlException(
                            SR.GetString(SR.InvalidSequenceNumber, maxMessageNumber)));
                    }
                    // otherwise ignore value

                    detailReader.ReadEndElement();
                }
            }
            finally
            {
                detailReader.Close();
            }
        }
 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;
 }
            public override SecurityKeyIdentifierClause ReadKeyIdentifierClauseCore( XmlDictionaryReader reader )
            {
                SecurityKeyIdentifierClause ski = null;
                reader.ReadStartElement( XD.XmlSignatureDictionary.X509Data, NamespaceUri );
                while ( reader.IsStartElement() )
                {
                    if ( ski == null && reader.IsStartElement( XD.XmlSignatureDictionary.X509Certificate, NamespaceUri ) )
                    {
                        X509Certificate2 certificate = null;
                        if ( !SecurityUtils.TryCreateX509CertificateFromRawData( reader.ReadElementContentAsBase64(), out certificate ) )
                        {
                            throw DiagnosticUtility.ExceptionUtility.ThrowHelperError( new SecurityMessageSerializationException( SR.GetString( SR.InvalidX509RawData ) ) );
                        }
                        ski = new X509RawDataKeyIdentifierClause( certificate );
                    }
                    else if ( ski == null && reader.IsStartElement( XmlSignatureStrings.X509Ski, NamespaceUri.ToString() ) )
                    {
                        ski = new X509SubjectKeyIdentifierClause( reader.ReadElementContentAsBase64() );
                    }
                    else if ( ( ski == null ) && reader.IsStartElement( XD.XmlSignatureDictionary.X509IssuerSerial, XD.XmlSignatureDictionary.Namespace ) )
                    {
                        reader.ReadStartElement( XD.XmlSignatureDictionary.X509IssuerSerial, XD.XmlSignatureDictionary.Namespace );
                        reader.ReadStartElement( XD.XmlSignatureDictionary.X509IssuerName, XD.XmlSignatureDictionary.Namespace );
                        string issuerName = reader.ReadContentAsString();
                        reader.ReadEndElement();
                        reader.ReadStartElement( XD.XmlSignatureDictionary.X509SerialNumber, XD.XmlSignatureDictionary.Namespace );
                        string serialNumber = reader.ReadContentAsString();
                        reader.ReadEndElement();
                        reader.ReadEndElement();

                        ski = new X509IssuerSerialKeyIdentifierClause( issuerName, serialNumber );
                    }
                    else
                    {
                        reader.Skip();
                    }
                }
                reader.ReadEndElement();
                return ski;
            }
 public override SecurityKeyIdentifierClause ReadClause(XmlDictionaryReader reader, byte[] derivationNonce, int derivationLength, string tokenType)
 {
     byte[] bytes;
     string attribute = reader.GetAttribute(XD.SecurityJan2004Dictionary.EncodingType, null);
     if (attribute == null)
     {
         attribute = this.DefaultEncodingType;
     }
     reader.ReadStartElement();
     if (attribute == "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary")
     {
         bytes = reader.ReadContentAsBase64();
     }
     else if (attribute == "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#HexBinary")
     {
         bytes = SoapHexBinary.Parse(reader.ReadContentAsString()).Value;
     }
     else
     {
         if (attribute != "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Text")
         {
             throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(System.ServiceModel.SR.GetString("UnknownEncodingInKeyIdentifier")));
         }
         bytes = new UTF8Encoding().GetBytes(reader.ReadContentAsString());
     }
     reader.ReadEndElement();
     return this.CreateClause(bytes, derivationNonce, derivationLength);
 }
 public override SecurityKeyIdentifierClause ReadClause(XmlDictionaryReader reader, byte[] derivationNonce, int derivationLength, string tokenType)
 {
     reader.ReadStartElement(XD.XmlSignatureDictionary.X509Data, XD.XmlSignatureDictionary.Namespace);
     reader.ReadStartElement(XD.XmlSignatureDictionary.X509IssuerSerial, XD.XmlSignatureDictionary.Namespace);
     reader.ReadStartElement(XD.XmlSignatureDictionary.X509IssuerName, XD.XmlSignatureDictionary.Namespace);
     string issuerName = reader.ReadContentAsString();
     reader.ReadEndElement();
     reader.ReadStartElement(XD.XmlSignatureDictionary.X509SerialNumber, XD.XmlSignatureDictionary.Namespace);
     string issuerSerialNumber = reader.ReadContentAsString();
     reader.ReadEndElement();
     reader.ReadEndElement();
     reader.ReadEndElement();
     return new X509IssuerSerialKeyIdentifierClause(issuerName, issuerSerialNumber);
 }
            public override SecurityKeyIdentifierClause ReadClause(XmlDictionaryReader reader, byte[] derivationNonce, int derivationLength, string tokenType)
            {
                string encodingType = reader.GetAttribute(XD.SecurityJan2004Dictionary.EncodingType, null);
                if (encodingType == null)
                {
                    encodingType = DefaultEncodingType;
                }

                reader.ReadStartElement();

                byte[] bytes;
                if (encodingType == EncodingTypeValueBase64Binary)
                {
                    bytes = reader.ReadContentAsBase64();
                }
                else if (encodingType == EncodingTypeValueHexBinary)
                {
                    bytes = HexBinary.Parse(reader.ReadContentAsString()).Value;
                }
                else if (encodingType == EncodingTypeValueText)
                {
                    bytes = new UTF8Encoding().GetBytes(reader.ReadContentAsString());
                }
                else
                {
                    throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityMessageSerializationException(SR.GetString(SR.UnknownEncodingInKeyIdentifier)));
                }

                reader.ReadEndElement();

                return CreateClause(bytes, derivationNonce, derivationLength);
            }
 public UnsupportedSelectionFault(Message message, FaultCode code, FaultReason reason, XmlDictionaryReader detailReader)
     : base(message, code, MakeConnectionConstants.Fault.UnsupportedSelectionFault, reason)
 {
     if (detailReader != null)
     {
         try
         {
             detailReader.ReadStartElement(MakeConnectionConstants.Fault.UnsupportedSelectionFault, MakeConnectionConstants.Namespace);
             this.elementName = detailReader.ReadContentAsString();
             detailReader.ReadEndElement();
         }
         finally
         {
             detailReader.Close();
         }
     }
 }