本文整理汇总了C#中System.Xml.XmlDictionaryReader.LookupNamespace方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDictionaryReader.LookupNamespace方法的具体用法?C# XmlDictionaryReader.LookupNamespace怎么用?C# XmlDictionaryReader.LookupNamespace使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDictionaryReader
的用法示例。
在下文中一共展示了XmlDictionaryReader.LookupNamespace方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadFrom
public override void ReadFrom(XmlDictionaryReader reader, TransformFactory transformFactory, DictionaryManager dictionaryManager)
{
reader.MoveToStartElement(XmlSignatureConstants.Elements.SignedInfo, XmlSignatureConstants.Namespace);
SendSide = false;
_defaultNamespace = reader.LookupNamespace(String.Empty);
_bufferedStream = new MemoryStream();
XmlWriterSettings settings = new XmlWriterSettings();
settings.Encoding = Encoding.UTF8;
settings.NewLineHandling = NewLineHandling.None;
using (XmlWriter bufferWriter = XmlTextWriter.Create(_bufferedStream, settings))
{
bufferWriter.WriteNode(reader, true);
bufferWriter.Flush();
}
_bufferedStream.Position = 0;
//
// We are creating a XmlDictionaryReader with a hard-coded Max XmlDictionaryReaderQuotas. This is a reader that we
// are creating over an already buffered content. The content was initially read off user provided XmlDictionaryReader
// with the correct quotas and hence we know the data is valid.
// Note: effectiveReader will close _bufferedStream on Dispose.
//
using (XmlDictionaryReader effectiveReader = XmlDictionaryReader.CreateTextReader(_bufferedStream, XmlDictionaryReaderQuotas.Max))
{
CanonicalStream = new MemoryStream();
effectiveReader.StartCanonicalization(CanonicalStream, false, null);
effectiveReader.MoveToStartElement(XmlSignatureConstants.Elements.SignedInfo, XmlSignatureConstants.Namespace);
Prefix = effectiveReader.Prefix;
Id = effectiveReader.GetAttribute(WSSecurityUtilityConstants.Attributes.Id, null);
effectiveReader.Read();
ReadCanonicalizationMethod(effectiveReader, DictionaryManager);
ReadSignatureMethod(effectiveReader, DictionaryManager);
while (effectiveReader.IsStartElement(XmlSignatureConstants.Elements.Reference, XmlSignatureConstants.Namespace))
{
Reference reference = new Reference(DictionaryManager);
reference.ReadFrom(effectiveReader, transformFactory, DictionaryManager);
AddReference(reference);
}
effectiveReader.ReadEndElement();
effectiveReader.EndCanonicalization();
}
string[] inclusivePrefixes = GetInclusivePrefixes();
if (inclusivePrefixes != null)
{
// Clear the canonicalized stream. We cannot use this while inclusive prefixes are
// specified.
CanonicalStream = null;
Context = new Dictionary<string, string>(inclusivePrefixes.Length);
for (int i = 0; i < inclusivePrefixes.Length; i++)
{
Context.Add(inclusivePrefixes[i], reader.LookupNamespace(inclusivePrefixes[i]));
}
}
}
示例2: ReadXml
public virtual void ReadXml(XmlDictionaryReader reader, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer, SecurityTokenResolver outOfBandTokenResolver)
{
string str2;
string str3;
if (reader == null)
{
throw System.IdentityModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("reader"));
}
if (samlSerializer == null)
{
throw System.IdentityModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSerializer"));
}
SamlDictionary samlDictionary = samlSerializer.DictionaryManager.SamlDictionary;
string attribute = reader.GetAttribute(samlDictionary.AuthorityKind, null);
if (string.IsNullOrEmpty(attribute))
{
throw System.IdentityModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(System.IdentityModel.SR.GetString("SAMLAuthorityBindingMissingAuthorityKindOnRead")));
}
string[] strArray = attribute.Split(new char[] { ':' });
if (strArray.Length > 2)
{
throw System.IdentityModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(System.IdentityModel.SR.GetString("SAMLAuthorityBindingInvalidAuthorityKind")));
}
if (strArray.Length == 2)
{
str3 = strArray[0];
str2 = strArray[1];
}
else
{
str3 = string.Empty;
str2 = strArray[0];
}
string ns = reader.LookupNamespace(str3);
this.authorityKind = new XmlQualifiedName(str2, ns);
this.binding = reader.GetAttribute(samlDictionary.Binding, null);
if (string.IsNullOrEmpty(this.binding))
{
throw System.IdentityModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(System.IdentityModel.SR.GetString("SAMLAuthorityBindingMissingBindingOnRead")));
}
this.location = reader.GetAttribute(samlDictionary.Location, null);
if (string.IsNullOrEmpty(this.location))
{
throw System.IdentityModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(System.IdentityModel.SR.GetString("SAMLAuthorityBindingMissingLocationOnRead")));
}
if (reader.IsEmptyElement)
{
reader.MoveToContent();
reader.Read();
}
else
{
reader.MoveToContent();
reader.Read();
reader.ReadEndElement();
}
}
示例3: ReadXml
public virtual void ReadXml(XmlDictionaryReader reader, SamlSerializer samlSerializer, SecurityTokenSerializer keyInfoSerializer, SecurityTokenResolver outOfBandTokenResolver)
{
if (reader == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("reader"));
if (samlSerializer == null)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentNullException("samlSerializer"));
#pragma warning suppress 56506 // samlSerializer.DictionaryManager is never null.
SamlDictionary dictionary = samlSerializer.DictionaryManager.SamlDictionary;
string authKind = reader.GetAttribute(dictionary.AuthorityKind, null);
if (string.IsNullOrEmpty(authKind))
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAuthorityBindingMissingAuthorityKindOnRead)));
string[] authKindParts = authKind.Split(':');
if (authKindParts.Length > 2)
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAuthorityBindingInvalidAuthorityKind)));
string localName;
string prefix;
string nameSpace;
if (authKindParts.Length == 2)
{
prefix = authKindParts[0];
localName = authKindParts[1];
}
else
{
prefix = String.Empty;
localName = authKindParts[0];
}
nameSpace = reader.LookupNamespace(prefix);
this.authorityKind = new XmlQualifiedName(localName, nameSpace);
this.binding = reader.GetAttribute(dictionary.Binding, null);
if (string.IsNullOrEmpty(this.binding))
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAuthorityBindingMissingBindingOnRead)));
this.location = reader.GetAttribute(dictionary.Location, null);
if (string.IsNullOrEmpty(this.location))
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new SecurityTokenException(SR.GetString(SR.SAMLAuthorityBindingMissingLocationOnRead)));
if (reader.IsEmptyElement)
{
reader.MoveToContent();
reader.Read();
}
else
{
reader.MoveToContent();
reader.Read();
reader.ReadEndElement();
}
}