本文整理汇总了C#中System.Xml.XmlDictionaryReader.ReadElementContentAsBase64方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDictionaryReader.ReadElementContentAsBase64方法的具体用法?C# XmlDictionaryReader.ReadElementContentAsBase64怎么用?C# XmlDictionaryReader.ReadElementContentAsBase64使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDictionaryReader
的用法示例。
在下文中一共展示了XmlDictionaryReader.ReadElementContentAsBase64方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ReadObject
/// <summary>
/// Reads the XML stream or document with an <see cref="T:System.Xml.XmlDictionaryReader" /> and returns the deserialized object; it also enables you to specify whether the serializer can read the data before attempting to read it.
/// </summary>
/// <param name="reader">An <see cref="T:System.Xml.XmlDictionaryReader" /> used to read the XML document.</param>
/// <param name="verifyObjectName">true to check whether the enclosing XML element name and namespace correspond to the root name and root namespace; otherwise, false to skip the verification.</param>
/// <returns>
/// The deserialized object.
/// </returns>
public override object ReadObject(XmlDictionaryReader reader, bool verifyObjectName)
{
Argument.IsNotNull("reader", reader);
var memoryStream = new MemoryStream(reader.ReadElementContentAsBase64());
return BinarySerializerHelper.DiscoverAndDeSerialize(memoryStream, _type);
}
示例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;
}
}
示例3: ReadValue
public object ReadValue(XmlDictionaryReader reader)
{
object value;
if (_isArray)
{
switch (_typeCode)
{
case TypeCode.Byte:
value = reader.ReadElementContentAsBase64();
break;
case TypeCode.Boolean:
if (!reader.IsEmptyElement)
{
reader.ReadStartElement();
value = reader.ReadBooleanArray(_itemName, _itemNamespace);
reader.ReadEndElement();
}
else
{
reader.Read();
value = Array.Empty<bool>();
}
break;
case TypeCode.DateTime:
if (!reader.IsEmptyElement)
{
reader.ReadStartElement();
value = reader.ReadDateTimeArray(_itemName, _itemNamespace);
reader.ReadEndElement();
}
else
{
reader.Read();
value = Array.Empty<DateTime>();
}
break;
case TypeCode.Decimal:
if (!reader.IsEmptyElement)
{
reader.ReadStartElement();
value = reader.ReadDecimalArray(_itemName, _itemNamespace);
reader.ReadEndElement();
}
else
{
reader.Read();
value = Array.Empty<Decimal>();
}
break;
case TypeCode.Int32:
if (!reader.IsEmptyElement)
{
reader.ReadStartElement();
value = reader.ReadInt32Array(_itemName, _itemNamespace);
reader.ReadEndElement();
}
else
{
reader.Read();
value = Array.Empty<Int32>();
}
break;
case TypeCode.Int64:
if (!reader.IsEmptyElement)
{
reader.ReadStartElement();
value = reader.ReadInt64Array(_itemName, _itemNamespace);
reader.ReadEndElement();
}
else
{
reader.Read();
value = Array.Empty<Int64>();
}
break;
case TypeCode.Single:
if (!reader.IsEmptyElement)
{
reader.ReadStartElement();
value = reader.ReadSingleArray(_itemName, _itemNamespace);
reader.ReadEndElement();
}
else
{
reader.Read();
value = Array.Empty<Single>();
}
break;
case TypeCode.Double:
if (!reader.IsEmptyElement)
{
reader.ReadStartElement();
value = reader.ReadDoubleArray(_itemName, _itemNamespace);
reader.ReadEndElement();
}
else
{
reader.Read();
value = Array.Empty<Double>();
}
//.........这里部分代码省略.........
示例4: ReadTokenCore
public override SecurityToken ReadTokenCore(XmlDictionaryReader reader, SecurityTokenResolver tokenResolver)
{
string wsuId = reader.GetAttribute(XD.UtilityDictionary.IdAttribute, XD.UtilityDictionary.Namespace);
string valueTypeUri = reader.GetAttribute(ValueTypeAttribute, null);
string encoding = reader.GetAttribute(EncodingTypeAttribute, null);
byte[] binaryData;
if (encoding == null || encoding == EncodingTypeValueBase64Binary)
{
binaryData = reader.ReadElementContentAsBase64();
}
else if (encoding == EncodingTypeValueHexBinary)
{
binaryData = HexBinary.Parse(reader.ReadElementContentAsString()).Value;
}
else
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(SR.GetString(SR.UnknownEncodingInBinarySecurityToken)));
}
return ReadBinaryCore(wsuId, valueTypeUri, binaryData);
}
示例5: ReadValue
public object ReadValue(XmlDictionaryReader reader)
{
object obj2;
if (!this.isArray)
{
switch (this.typeCode)
{
case TypeCode.Int32:
return reader.ReadElementContentAsInt();
case TypeCode.Int64:
return reader.ReadElementContentAsLong();
case TypeCode.Single:
return reader.ReadElementContentAsFloat();
case TypeCode.Double:
return reader.ReadElementContentAsDouble();
case TypeCode.Decimal:
return reader.ReadElementContentAsDecimal();
case TypeCode.DateTime:
return reader.ReadElementContentAsDateTime();
case TypeCode.String:
return reader.ReadElementContentAsString();
case TypeCode.Boolean:
return reader.ReadElementContentAsBoolean();
}
throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("SFxInvalidUseOfPrimitiveOperationFormatter")));
}
switch (this.typeCode)
{
case TypeCode.Boolean:
if (reader.IsEmptyElement)
{
reader.Read();
return new bool[0];
}
reader.ReadStartElement();
obj2 = reader.ReadBooleanArray(this.itemName, this.itemNamespace);
reader.ReadEndElement();
return obj2;
case TypeCode.Byte:
return reader.ReadElementContentAsBase64();
case TypeCode.Int32:
if (reader.IsEmptyElement)
{
reader.Read();
return new int[0];
}
reader.ReadStartElement();
obj2 = reader.ReadInt32Array(this.itemName, this.itemNamespace);
reader.ReadEndElement();
return obj2;
case TypeCode.Int64:
if (reader.IsEmptyElement)
{
reader.Read();
return new long[0];
}
reader.ReadStartElement();
obj2 = reader.ReadInt64Array(this.itemName, this.itemNamespace);
reader.ReadEndElement();
return obj2;
case TypeCode.Single:
if (reader.IsEmptyElement)
{
reader.Read();
return new float[0];
}
reader.ReadStartElement();
obj2 = reader.ReadSingleArray(this.itemName, this.itemNamespace);
reader.ReadEndElement();
return obj2;
case TypeCode.Double:
if (reader.IsEmptyElement)
{
reader.Read();
return new double[0];
}
reader.ReadStartElement();
obj2 = reader.ReadDoubleArray(this.itemName, this.itemNamespace);
reader.ReadEndElement();
return obj2;
case TypeCode.Decimal:
if (reader.IsEmptyElement)
{
reader.Read();
return new decimal[0];
}
reader.ReadStartElement();
//.........这里部分代码省略.........
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:101,代码来源:PrimitiveOperationFormatter.cs
示例6: 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;
}
示例7: CreateRawDataKeyIdentifierClause
/// <summary>
/// Parses the "X509Certificate" element and generates a corresponding <see cref="X509RawDataKeyIdentifierClause"/> instance.
/// </summary>
/// <param name="dictionaryReader">The <see cref="XmlDictionaryReader"/> currently positioning on the "X509Certificate" element. </param>
/// <returns>An instance of <see cref="X509RawDataKeyIdentifierClause"/> created from the "X509Certificate" element.</returns>
private static SecurityKeyIdentifierClause CreateRawDataKeyIdentifierClause(XmlDictionaryReader dictionaryReader)
{
#if INCLUDE_CERT_CHAIN
List<byte[]> rawDatas = new List<byte[]>();
while (dictionaryReader.IsStartElement(XmlSignatureConstants.Elements.X509Certificate, XmlSignatureConstants.Namespace))
{
byte[] rawBuffer = dictionaryReader.ReadElementContentAsBase64();
if (rawBuffer == null || rawBuffer.Length == 0)
{
throw DiagnosticUtility.ThrowHelperInvalidOperation(SR.GetString(SR.ID4258, XmlSignatureConstants.Elements.X509Certificate, XmlSignatureConstants.Namespace));
}
rawDatas.Add(rawBuffer);
}
if (rawDatas.Count > 1)
{
return new X509ChainRawDataKeyIdentifierClause(rawDatas);
}
else
{
return new X509RawDataKeyIdentifierClause(rawDatas[0]);
}
#else
byte[] rawData = null;
while (dictionaryReader.IsStartElement(XmlSignatureConstants.Elements.X509Certificate, XmlSignatureConstants.Namespace))
{
if (rawData == null)
{
rawData = dictionaryReader.ReadElementContentAsBase64();
if ((rawData == null) || (rawData.Length == 0))
{
throw DiagnosticUtility.ThrowHelperInvalidOperation(SR.GetString(SR.ID4258, XmlSignatureConstants.Elements.X509Certificate, XmlSignatureConstants.Namespace));
}
}
else
{
// We do not support reading intermediary certs.
dictionaryReader.Skip();
}
}
return new X509RawDataKeyIdentifierClause(rawData);
#endif
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:50,代码来源:X509DataSecurityKeyIdentifierClauseSerializer.cs
示例8: CreateSubjectKeyIdentifierClause
/// <summary>
/// Parses the "X509SKI" element and generates a corresponding <see cref="SecurityKeyIdentifierClause"/> instance.
/// </summary>
/// <param name="dictionaryReader">The <see cref="XmlDictionaryReader"/> currently positioning on the "X509SKI" element. </param>
/// <returns>An instance of <see cref="X509SubjectKeyIdentifierClause"/> created from the "X509SKI" element.</returns>
private static SecurityKeyIdentifierClause CreateSubjectKeyIdentifierClause(XmlDictionaryReader dictionaryReader)
{
byte[] ski = dictionaryReader.ReadElementContentAsBase64();
if ((ski == null) || (ski.Length == 0))
{
throw DiagnosticUtility.ThrowHelperInvalidOperation(SR.GetString(SR.ID4258, XmlSignatureConstants.Elements.X509SKI, XmlSignatureConstants.Namespace));
}
return new X509SubjectKeyIdentifierClause(ski);
}
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:15,代码来源:X509DataSecurityKeyIdentifierClauseSerializer.cs
示例9: Deserialize
public static object Deserialize(XmlDictionaryReader reader, Type targetType)
{
object returnValue = null;
if (reader.IsStartElement())
{
switch (reader.LocalName)
{
case XmlRpcProtocol.Nil:
returnValue = null;
break;
case XmlRpcProtocol.Bool:
returnValue = Convert.ChangeType((reader.ReadElementContentAsInt()==1),targetType);
break;
case XmlRpcProtocol.ByteArray:
if (targetType == typeof(Stream))
{
returnValue = new MemoryStream(reader.ReadElementContentAsBase64());
}
else
{
returnValue = Convert.ChangeType(reader.ReadElementContentAsBase64(), targetType);
}
break;
case XmlRpcProtocol.DateTime:
returnValue = Convert.ChangeType(reader.ReadElementContentAsDateTime(),targetType);
break;
case XmlRpcProtocol.Double:
returnValue = Convert.ChangeType(reader.ReadElementContentAsDouble(),targetType);
break;
case XmlRpcProtocol.Int32:
case XmlRpcProtocol.Integer:
returnValue = Convert.ChangeType(reader.ReadElementContentAsString(),targetType);
break;
case XmlRpcProtocol.String:
if (targetType == typeof(Uri))
{
returnValue = new Uri(reader.ReadElementContentAsString());
}
else
{
returnValue = Convert.ChangeType(reader.ReadElementContentAsString(), targetType);
}
break;
case XmlRpcProtocol.Struct:
returnValue = DeserializeStruct(reader, targetType);
break;
case XmlRpcProtocol.Array:
if (targetType.IsArray || targetType is IEnumerable || targetType is IList || targetType is ICollection)
{
reader.ReadStartElement(XmlRpcProtocol.Array);
ArrayList arrayData = new ArrayList();
reader.ReadStartElement(XmlRpcProtocol.Data);
reader.MoveToContent();
while (reader.IsStartElement(XmlRpcProtocol.Value))
{
reader.ReadStartElement();
arrayData.Add(Deserialize(reader, targetType.GetElementType()));
reader.ReadEndElement();
reader.MoveToContent();
}
if (reader.NodeType == XmlNodeType.EndElement && reader.LocalName == XmlRpcProtocol.Data)
{
reader.ReadEndElement();
}
reader.ReadEndElement();
if (targetType is IEnumerable || targetType is IList || targetType is ICollection)
{
returnValue = arrayData;
}
else
{
returnValue = arrayData.ToArray(targetType.GetElementType());
}
}
else
{
throw new InvalidOperationException();
}
break;
}
}
return returnValue;
}
开发者ID:ehabqadah,项目名称:Distributed-Nodes-Network-Management,代码行数:85,代码来源:XmlRpcDataContractSerializer.cs
示例10: ReadKeyIdentifierClauseCore
public override SecurityKeyIdentifierClause ReadKeyIdentifierClauseCore(XmlDictionaryReader reader)
{
byte[] secret = reader.ReadElementContentAsBase64();
return new BinarySecretKeyIdentifierClause(secret, false);
}
示例11: ReadTokenCore
public override SecurityToken ReadTokenCore(XmlDictionaryReader reader, SecurityTokenResolver tokenResolver)
{
byte[] buffer;
string attribute = reader.GetAttribute(XD.UtilityDictionary.IdAttribute, XD.UtilityDictionary.Namespace);
string valueTypeUri = reader.GetAttribute(ValueTypeAttribute, null);
string str3 = reader.GetAttribute(EncodingTypeAttribute, null);
switch (str3)
{
case null:
case "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary":
buffer = reader.ReadElementContentAsBase64();
break;
default:
if (str3 != "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#HexBinary")
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(System.ServiceModel.SR.GetString("UnknownEncodingInBinarySecurityToken")));
}
buffer = SoapHexBinary.Parse(reader.ReadElementContentAsString()).Value;
break;
}
return this.ReadBinaryCore(attribute, valueTypeUri, buffer);
}
示例12: ReadTokenCore
public override SecurityToken ReadTokenCore(XmlDictionaryReader reader, SecurityTokenResolver tokenResolver)
{
UniqueId contextId = null;
byte[] encodedCookie = null;
UniqueId generation = null;
bool isCookieMode = false;
Fx.Assert(reader.NodeType == XmlNodeType.Element, "");
// check if there is an id
string id = reader.GetAttribute(XD.UtilityDictionary.IdAttribute, XD.UtilityDictionary.Namespace);
SecurityContextSecurityToken sct = null;
// There needs to be at least a contextId in here.
reader.ReadFullStartElement();
reader.MoveToStartElement(parent.SerializerDictionary.Identifier, parent.SerializerDictionary.Namespace);
contextId = reader.ReadElementContentAsUniqueId();
if (CanReadGeneration(reader))
{
generation = ReadGeneration(reader);
}
if (reader.IsStartElement(parent.SerializerDictionary.Cookie, XD.DotNetSecurityDictionary.Namespace))
{
isCookieMode = true;
ISecurityContextSecurityTokenCache sctCache;
sct = TryResolveSecurityContextToken(contextId, generation, id, tokenResolver, out sctCache);
if (sct == null)
{
encodedCookie = reader.ReadElementContentAsBase64();
if (encodedCookie != null)
{
sct = cookieSerializer.CreateSecurityContextFromCookie(encodedCookie, contextId, generation, id, reader.Quotas);
if (sctCache != null)
{
sctCache.AddContext(sct);
}
}
}
else
{
reader.Skip();
}
}
reader.ReadEndElement();
if (contextId == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new MessageSecurityException(SR.GetString(SR.NoSecurityContextIdentifier)));
}
if (sct == null && !isCookieMode)
{
ISecurityContextSecurityTokenCache sctCache;
sct = TryResolveSecurityContextToken(contextId, generation, id, tokenResolver, out sctCache);
}
if (sct == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperWarning(new SecurityContextTokenValidationException(SR.GetString(SR.SecurityContextNotRegistered, contextId, generation)));
}
return sct;
}
示例13: ReadObject
public override object ReadObject(XmlDictionaryReader reader, bool verifyObjectName)
{
if (this.isCustomSerialization)
{
var result = Activator.CreateInstance(this.type);
using (var ms = new MemoryStream(reader.ReadElementContentAsBase64()))
{
((ICustomSerializable)result).InitializeFrom(ms);
}
return result;
}
else
{
return this.fallbackSerializer.ReadObject(reader, verifyObjectName);
}
}