本文整理汇总了C#中System.Xml.XmlDictionaryReader.ReadContentAsString方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDictionaryReader.ReadContentAsString方法的具体用法?C# XmlDictionaryReader.ReadContentAsString怎么用?C# XmlDictionaryReader.ReadContentAsString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDictionaryReader
的用法示例。
在下文中一共展示了XmlDictionaryReader.ReadContentAsString方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: X509CertificateEndpointIdentity
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)));
}
示例2: DeserializeStruct
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();
}
}
开发者ID:ehabqadah,项目名称:Distributed-Nodes-Network-Management,代码行数:55,代码来源:XmlRpcDataContractSerializer.cs
示例3: DeserializeJsonAsFlatDictionary
/// <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;
}
}
示例4: MessageNumberRolloverFault
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();
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:21,代码来源:MessageNumberRolloverFault.cs
示例5: MessageNumberRolloverFault
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();
}
}
示例6: 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;
}
示例7: ReadKeyIdentifierClauseCore
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;
}
示例8: ReadClause
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);
}
示例9: ReadClause
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);
}
示例10: UnsupportedSelectionFault
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();
}
}
}