本文整理匯總了C#中System.Xml.XmlDictionaryWriter.WriteBinHex方法的典型用法代碼示例。如果您正苦於以下問題:C# XmlDictionaryWriter.WriteBinHex方法的具體用法?C# XmlDictionaryWriter.WriteBinHex怎麽用?C# XmlDictionaryWriter.WriteBinHex使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類System.Xml.XmlDictionaryWriter
的用法示例。
在下文中一共展示了XmlDictionaryWriter.WriteBinHex方法的3個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。
示例1: WriteContent
public override void WriteContent(XmlDictionaryWriter writer, SecurityKeyIdentifierClause clause)
{
writer.WriteStartElement(XD.SecurityJan2004Dictionary.Prefix.Value, XD.SecurityJan2004Dictionary.KeyIdentifier, XD.SecurityJan2004Dictionary.Namespace);
writer.WriteAttributeString(XD.SecurityJan2004Dictionary.ValueType, null, this.ValueTypeUri);
if (this.tokenSerializer.EmitBspRequiredAttributes)
{
writer.WriteAttributeString(XD.SecurityJan2004Dictionary.EncodingType, null, this.DefaultEncodingType);
}
string defaultEncodingType = this.DefaultEncodingType;
byte[] buffer = (clause as BinaryKeyIdentifierClause).GetBuffer();
switch (defaultEncodingType)
{
case "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Base64Binary":
writer.WriteBase64(buffer, 0, buffer.Length);
break;
case "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#HexBinary":
writer.WriteBinHex(buffer, 0, buffer.Length);
break;
case "http://docs.oasis-open.org/wss/2004/01/oasis-200401-wss-soap-message-security-1.0#Text":
writer.WriteString(new UTF8Encoding().GetString(buffer, 0, buffer.Length));
break;
}
writer.WriteEndElement();
}
示例2: WriteObjectContent
public override void WriteObjectContent(XmlDictionaryWriter writer, object graph)
{
if (this.isCustomSerialization)
{
DataContractJsonSerializer ser = new DataContractJsonSerializer(this.type);
using (MemoryStream ms = new MemoryStream())
{
if (m_IsCompress)
{
using (DeflateStream ds = new DeflateStream(ms, CompressionMode.Compress))
{
ser.WriteObject(ds, graph);
ds.Flush();
ds.Close();
}
}
else
{
ser.WriteObject(ms, graph);
}
byte[] compressed = ms.ToArray();
if (!m_IsCompress)
{
switch (m_ContentType)
{
case SerializeContentTypes.String:
string value = Encoding.UTF8.GetString(compressed);
writer.WriteString(value);
break;
case SerializeContentTypes.BinHex:
writer.WriteBinHex(compressed, 0, compressed.Length);
break;
}
}
else
{
writer.WriteBinHex(compressed, 0, compressed.Length);
}
}
}
else
{
this.fallbackSerializer.WriteObjectContent(writer, graph);
}
}
示例3: WriteContent
public override void WriteContent(XmlDictionaryWriter writer, SecurityKeyIdentifierClause clause)
{
writer.WriteStartElement(XD.SecurityJan2004Dictionary.Prefix.Value, XD.SecurityJan2004Dictionary.KeyIdentifier, XD.SecurityJan2004Dictionary.Namespace);
writer.WriteAttributeString(XD.SecurityJan2004Dictionary.ValueType, null, ValueTypeUri);
KerberosTicketHashKeyIdentifierClause binaryClause = clause as KerberosTicketHashKeyIdentifierClause;
if (this.EmitBspRequiredAttributes)
{
// Emit the encodingType attribute.
writer.WriteAttributeString(XD.SecurityJan2004Dictionary.EncodingType, null, DefaultEncodingType);
}
string encoding = DefaultEncodingType;
byte[] keyIdentifier = binaryClause.GetBuffer();
if (encoding == EncodingTypeValueBase64Binary)
{
writer.WriteBase64(keyIdentifier, 0, keyIdentifier.Length);
}
else if (encoding == EncodingTypeValueHexBinary)
{
writer.WriteBinHex(keyIdentifier, 0, keyIdentifier.Length);
}
else if (encoding == EncodingTypeValueText)
{
writer.WriteString(new UTF8Encoding().GetString(keyIdentifier, 0, keyIdentifier.Length));
}
writer.WriteEndElement();
}