本文整理汇总了C#中System.Xml.XmlDictionaryWriter.WriteBase64方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDictionaryWriter.WriteBase64方法的具体用法?C# XmlDictionaryWriter.WriteBase64怎么用?C# XmlDictionaryWriter.WriteBase64使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDictionaryWriter
的用法示例。
在下文中一共展示了XmlDictionaryWriter.WriteBase64方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteObject
public override void WriteObject(XmlDictionaryWriter writer, object graph)
{
var data = EncodeObject(graph);
writer.WriteStartElement("Data");
writer.WriteBase64(data, 0, data.Length);
writer.WriteEndElement();
}
示例2: WriteHeader
private void WriteHeader(XmlDictionaryWriter writer)
{
var nonce = new byte[64];
RandomNumberGenerator.Create().GetBytes(nonce);
string created = DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.mszzzz");
writer.WriteStartElement("wsse", "UsernameToken", null);
writer.WriteAttributeString("wsu:Id", "UsernameToken-1");
writer.WriteStartElement("wsse", "Username", null);
writer.WriteString(SystemUser);
writer.WriteEndElement();//End Username
writer.WriteStartElement("wsse", "Password", null);
writer.WriteAttributeString("Type", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-username-token-profile-1.0#PasswordDigest");
writer.WriteString(ComputePasswordDigest(SystemPassword, nonce, created));
writer.WriteEndElement();//End Password
writer.WriteStartElement("wsse", "Nonce", null);
writer.WriteAttributeString("EncodingType", "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary");
writer.WriteBase64(nonce, 0, nonce.Length);
writer.WriteEndElement();//End Nonce
writer.WriteStartElement("wsu", "Created", null);
writer.WriteString(created);
writer.WriteEndElement();//End Created
writer.WriteEndElement();//End UsernameToken
writer.Flush();
}
示例3: WriteChunkCallback
void WriteChunkCallback(XmlDictionaryWriter writer, object state)
{
ChunkState chunkState = (ChunkState)state;
writer.WriteStartElement(ChunkingUtils.ChunkElement, ChunkingUtils.ChunkNs);
writer.WriteBase64(chunkState.Buffer, 0, chunkState.Count);
writer.WriteEndElement();
}
示例4: OnWriteBodyContents
/// <summary>
/// Writes the given content to output writer.
/// </summary>
/// <param name="writer">Output writer instance.</param>
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
var buffer = this.contentEncoding.GetBytes(this.content);
writer.WriteStartElement("Binary");
writer.WriteBase64(buffer, 0, buffer.Length);
writer.WriteEndElement();
}
示例5: OnWriteBodyContents
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
writer.WriteStartElement("Binary");
FileStream fs = new FileStream(this.testFileName, FileMode.Open);
byte[] tmp = new byte[fs.Length];
fs.Read(tmp, 0, tmp.Length);
writer.WriteBase64(tmp, 0, (int)tmp.Length);
writer.WriteEndElement();
fs.Close();
}
示例6: WriteTo
public void WriteTo(XmlDictionaryWriter writer, string prefix, XmlDictionaryString localName, XmlDictionaryString ns, XmlDictionaryString valueTypeLocalName, XmlDictionaryString valueTypeNs)
{
writer.WriteStartElement(prefix, localName, ns);
writer.WriteStartAttribute(valueTypeLocalName, valueTypeNs);
if (valueTypeUriDictionaryString != null)
writer.WriteString(valueTypeUriDictionaryString);
else
writer.WriteString(valueTypeUri);
writer.WriteEndAttribute();
writer.WriteStartAttribute(XD.SecurityJan2004Dictionary.EncodingType, null);
writer.WriteString(XD.SecurityJan2004Dictionary.EncodingTypeValueBase64Binary);
writer.WriteEndAttribute();
writer.WriteBase64(this.negotiationData, 0, this.negotiationData.Length);
writer.WriteEndElement();
}
示例7: OnWriteBodyContents
/// <summary>
/// Writes the body to the stream.
/// </summary>
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
if (m_isRequest)
{
writer.WriteStartElement("InvokeServiceRequest", Namespaces.OpcUaXsd);
}
else
{
writer.WriteStartElement("InvokeServiceResponse", Namespaces.OpcUaXsd);
}
if (m_data != null)
{
writer.WriteBase64(m_data, 0, m_data.Length);
}
writer.WriteEndElement();
}
示例8: WriteValue
public void WriteValue(XmlDictionaryWriter writer, object value)
{
if (_isArray)
{
switch (_typeCode)
{
case TypeCode.Byte:
{
byte[] arrayValue = (byte[])value;
writer.WriteBase64(arrayValue, 0, arrayValue.Length);
}
break;
case TypeCode.Boolean:
{
bool[] arrayValue = (bool[])value;
writer.WriteArray(null, _itemName, _itemNamespace, arrayValue, 0, arrayValue.Length);
}
break;
case TypeCode.DateTime:
{
DateTime[] arrayValue = (DateTime[])value;
writer.WriteArray(null, _itemName, _itemNamespace, arrayValue, 0, arrayValue.Length);
}
break;
case TypeCode.Decimal:
{
decimal[] arrayValue = (decimal[])value;
writer.WriteArray(null, _itemName, _itemNamespace, arrayValue, 0, arrayValue.Length);
}
break;
case TypeCode.Int32:
{
Int32[] arrayValue = (Int32[])value;
writer.WriteArray(null, _itemName, _itemNamespace, arrayValue, 0, arrayValue.Length);
}
break;
case TypeCode.Int64:
{
Int64[] arrayValue = (Int64[])value;
writer.WriteArray(null, _itemName, _itemNamespace, arrayValue, 0, arrayValue.Length);
}
break;
case TypeCode.Single:
{
float[] arrayValue = (float[])value;
writer.WriteArray(null, _itemName, _itemNamespace, arrayValue, 0, arrayValue.Length);
}
break;
case TypeCode.Double:
{
double[] arrayValue = (double[])value;
writer.WriteArray(null, _itemName, _itemNamespace, arrayValue, 0, arrayValue.Length);
}
break;
default:
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SFxInvalidUseOfPrimitiveOperationFormatter));
}
}
else
{
switch (_typeCode)
{
case TypeCode.Boolean:
writer.WriteValue((bool)value);
break;
case TypeCode.DateTime:
writer.WriteValue((DateTime)value);
break;
case TypeCode.Decimal:
writer.WriteValue((Decimal)value);
break;
case TypeCode.Double:
writer.WriteValue((double)value);
break;
case TypeCode.Int32:
writer.WriteValue((int)value);
break;
case TypeCode.Int64:
writer.WriteValue((long)value);
break;
case TypeCode.Single:
writer.WriteValue((float)value);
break;
case TypeCode.String:
writer.WriteString((string)value);
break;
default:
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(SR.SFxInvalidUseOfPrimitiveOperationFormatter));
}
}
}
示例9: OnWriteBodyContents
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
writer.WriteStartElement("Binary");
writer.WriteBase64(this.messageBytes, 0, this.messageBytes.Length);
writer.WriteEndElement();
}
示例10: OnWriteBodyContents
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
writer.WriteStartElement(BinaryBodyReader.BinaryElementName);
writer.WriteBase64(_data, 0, _data.Length);
writer.WriteEndElement();
}
示例11: OnWriteBodyContents
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
writer.WriteStartElement("Binary");
byte[] buffer = JSONPSupportInspector.encoding.GetBytes(this.content);
writer.WriteBase64(buffer, 0, buffer.Length);
writer.WriteEndElement();
}
示例12: OnWriteBodyContents
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
writer.WriteStartElement(StreamBodyWriter.StreamElementName);
byte[] buffer = new byte[BufferSize];
while (true)
{
int actual = this.stream.Read(buffer, 0, buffer.Length);
if (actual == 0)
{
break;
}
writer.WriteBase64(buffer, 0, actual);
}
//this.stream.Close();
writer.WriteEndElement();
}
示例13: WriteKeyIdentifierClauseCore
public override void WriteKeyIdentifierClauseCore(XmlDictionaryWriter writer, SecurityKeyIdentifierClause keyIdentifierClause)
{
EncryptedKeyIdentifierClause encryptedKeyClause = keyIdentifierClause as EncryptedKeyIdentifierClause;
writer.WriteStartElement(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.EncryptedKey, NamespaceUri);
if (encryptedKeyClause.EncryptionMethod != null)
{
writer.WriteStartElement(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.EncryptionMethod, NamespaceUri);
writer.WriteAttributeString(XD.XmlEncryptionDictionary.AlgorithmAttribute, null, encryptedKeyClause.EncryptionMethod);
if (encryptedKeyClause.EncryptionMethod == XD.SecurityAlgorithmDictionary.RsaOaepKeyWrap.Value)
{
writer.WriteStartElement(XmlSignatureStrings.Prefix, XD.XmlSignatureDictionary.DigestMethod, XD.XmlSignatureDictionary.Namespace);
writer.WriteAttributeString(XD.XmlSignatureDictionary.Algorithm, null, SecurityAlgorithms.Sha1Digest);
writer.WriteEndElement();
}
writer.WriteEndElement();
}
if (encryptedKeyClause.EncryptingKeyIdentifier != null)
{
this.securityTokenSerializer.WriteKeyIdentifier(writer, encryptedKeyClause.EncryptingKeyIdentifier);
}
writer.WriteStartElement(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.CipherData, NamespaceUri);
writer.WriteStartElement(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.CipherValue, NamespaceUri);
byte[] encryptedKey = encryptedKeyClause.GetEncryptedKey();
writer.WriteBase64(encryptedKey, 0, encryptedKey.Length);
writer.WriteEndElement();
writer.WriteEndElement();
if (encryptedKeyClause.CarriedKeyName != null)
{
writer.WriteElementString(XD.XmlEncryptionDictionary.Prefix.Value, XD.XmlEncryptionDictionary.CarriedKeyName, NamespaceUri, encryptedKeyClause.CarriedKeyName);
}
writer.WriteEndElement();
}
示例14: WriteTokenCore
public override void WriteTokenCore(XmlDictionaryWriter writer, SecurityToken token)
{
string id;
byte[] rawData;
WriteBinaryCore(token, out id, out rawData);
if (rawData == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("rawData");
}
writer.WriteStartElement(XD.SecurityJan2004Dictionary.Prefix.Value, ElementName, XD.SecurityJan2004Dictionary.Namespace);
if (id != null)
{
writer.WriteAttributeString(XD.UtilityDictionary.Prefix.Value, XD.UtilityDictionary.IdAttribute, XD.UtilityDictionary.Namespace, id);
}
if (valueTypeUris != null)
{
writer.WriteAttributeString(ValueTypeAttribute, null, this.valueTypeUris[0]);
}
if (this.tokenSerializer.EmitBspRequiredAttributes)
{
writer.WriteAttributeString(EncodingTypeAttribute, null, EncodingTypeValueBase64Binary);
}
writer.WriteBase64(rawData, 0, rawData.Length);
writer.WriteEndElement(); // BinarySecurityToken
}
示例15: WriteSignatureConfirmation
internal override void WriteSignatureConfirmation(XmlDictionaryWriter writer, string id, byte[] signature)
{
if (id == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("id");
}
if (signature == null)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("signature");
}
writer.WriteStartElement(XD.SecurityXXX2005Dictionary.Prefix.Value, XD.SecurityXXX2005Dictionary.SignatureConfirmation, XD.SecurityXXX2005Dictionary.Namespace);
writer.WriteAttributeString(XD.UtilityDictionary.Prefix.Value, XD.UtilityDictionary.IdAttribute, XD.UtilityDictionary.Namespace, id);
writer.WriteStartAttribute(XD.SecurityXXX2005Dictionary.ValueAttribute, null);
writer.WriteBase64(signature, 0, signature.Length);
writer.WriteEndAttribute();
writer.WriteEndElement();
}