本文整理汇总了C#中System.Xml.XmlDictionaryWriter类的典型用法代码示例。如果您正苦于以下问题:C# XmlDictionaryWriter类的具体用法?C# XmlDictionaryWriter怎么用?C# XmlDictionaryWriter使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
XmlDictionaryWriter类属于System.Xml命名空间,在下文中一共展示了XmlDictionaryWriter类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddPrefixIfNeeded
protected virtual void AddPrefixIfNeeded(XmlDictionaryWriter writer, string prefix, string ns)
{
if (writer.LookupPrefix(ns) == null)
{
writer.WriteXmlnsAttribute(prefix, ns);
}
}
示例2: WriteObject
public override void WriteObject(XmlDictionaryWriter writer, object graph)
{
if (_isSerializerSetExplicit)
_serializer.Serialize(writer, new object[] { graph });
else
_serializer.Serialize(writer, graph);
}
示例3: OnWriteBodyContents
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
using (XmlWriterBackedStream stream = new XmlWriterBackedStream(writer))
{
OnWriteBodyContents(stream);
}
}
示例4: 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();
}
示例5: OnWriteBodyContents
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
if (_data != null && _data.Length > 0)
{
writer.WriteElementString("BODY", _data);
}
}
示例6: 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();
}
示例7: SerializeAsync
internal async Task SerializeAsync(XmlDictionaryWriter writer, object[] parameters, object returnValue)
{
Stream streamValue = await GetStreamAndWriteStartWrapperIfNecessaryAsync(writer, parameters, returnValue);
var streamProvider = new OperationStreamProvider(streamValue);
await StreamFormatterHelper.WriteValueAsync(writer, streamProvider);
await WriteEndWrapperIfNecessaryAsync(writer);
}
示例8: WriteAckRanges
internal static void WriteAckRanges(XmlDictionaryWriter writer, ReliableMessagingVersion reliableMessagingVersion, UniqueId sequenceId, SequenceRangeCollection ranges)
{
WsrmFeb2005Dictionary dictionary = XD.WsrmFeb2005Dictionary;
XmlDictionaryString namespaceUri = WsrmIndex.GetNamespace(reliableMessagingVersion);
writer.WriteStartElement(dictionary.Identifier, namespaceUri);
writer.WriteValue(sequenceId);
writer.WriteEndElement();
if (ranges.Count == 0)
{
if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessagingFebruary2005)
{
ranges = ranges.MergeWith((long) 0L);
}
else if (reliableMessagingVersion == ReliableMessagingVersion.WSReliableMessaging11)
{
writer.WriteStartElement(DXD.Wsrm11Dictionary.None, namespaceUri);
writer.WriteEndElement();
}
}
for (int i = 0; i < ranges.Count; i++)
{
writer.WriteStartElement(dictionary.AcknowledgementRange, namespaceUri);
writer.WriteStartAttribute(dictionary.Lower, null);
SequenceRange range = ranges[i];
writer.WriteValue(range.Lower);
writer.WriteEndAttribute();
writer.WriteStartAttribute(dictionary.Upper, null);
SequenceRange range2 = ranges[i];
writer.WriteValue(range2.Upper);
writer.WriteEndAttribute();
writer.WriteEndElement();
}
}
示例9: OnWriteAddressHeaderContents
protected override void OnWriteAddressHeaderContents (XmlDictionaryWriter writer)
{
writer.WriteStartElement(XD.DotNetAtomicTransactionExternalDictionary.LocalTransactionId,
XD.DotNetAtomicTransactionExternalDictionary.Namespace);
writer.WriteValue(this.transactionId);
writer.WriteEndElement();
if (this.contextId != null)
{
writer.WriteStartElement(XD.DotNetAtomicTransactionExternalDictionary.ContextId,
XD.DotNetAtomicTransactionExternalDictionary.Namespace);
writer.WriteValue(this.contextId);
writer.WriteEndElement();
}
if (this.tokenId != null)
{
writer.WriteStartElement(XD.DotNetAtomicTransactionExternalDictionary.TokenId,
XD.DotNetAtomicTransactionExternalDictionary.Namespace);
writer.WriteValue(this.tokenId);
writer.WriteEndElement();
}
}
示例10: WriteObject
public override void WriteObject(XmlDictionaryWriter writer, object graph)
{
var data = EncodeObject(graph);
writer.WriteStartElement("Data");
writer.WriteBase64(data, 0, data.Length);
writer.WriteEndElement();
}
示例11: WriteAdditionalAttributes
protected override void WriteAdditionalAttributes(XmlDictionaryWriter writer)
{
if (this.recipient != null)
{
writer.WriteAttributeString(RecipientAttribute, null, this.recipient);
}
}
示例12: WriteEndObject
public override void WriteEndObject(XmlDictionaryWriter writer)
{
if (!skipName)
{
writer.WriteEndElement();
}
}
示例13: OnWriteStartAddressHeader
protected override void OnWriteStartAddressHeader(XmlDictionaryWriter writer)
{
XmlDictionaryReader addressHeaderReader = this.GetAddressHeaderReader();
writer.WriteStartElement(addressHeaderReader.Prefix, addressHeaderReader.LocalName, addressHeaderReader.NamespaceURI);
writer.WriteAttributes(addressHeaderReader, false);
addressHeaderReader.Close();
}
示例14: WriteJson
public void WriteJson(XmlDictionaryWriter writer)
{
writer.WriteStartElement(MetadataStrings.TypeString);
writer.WriteAttributeString("type", "string");
writer.WriteString(String.Format("{0}{1}{2}", this.TypeName, MetadataStrings.NamespaceMarker, this.TypeNamespace));
writer.WriteEndElement();
writer.WriteStartElement(MetadataStrings.KeyString);
writer.WriteAttributeString("type", "array");
foreach (string keyitem in this.Key)
{
writer.WriteStartElement("item");
writer.WriteAttributeString("type", "string");
writer.WriteValue(keyitem);
writer.WriteEndElement();
}
writer.WriteEndElement();
writer.WriteStartElement(MetadataStrings.FieldsString);
writer.WriteAttributeString("type", "object");
foreach (TypePropertyMetadata field in this.Properties)
{
field.WriteJson(writer);
}
writer.WriteEndElement();
this.WriteValidationRulesMetadata(writer);
}
示例15: Serialize
internal static void Serialize(MessageDictionary messageDictionary, XmlDictionaryWriter writer) {
Requires.NotNull(messageDictionary, "messageDictionary");
Requires.NotNull(writer, "writer");
writer.WriteStartElement("root");
writer.WriteAttributeString("type", "object");
foreach (var pair in messageDictionary) {
bool include = false;
string type = "string";
MessagePart partDescription;
if (messageDictionary.Description.Mapping.TryGetValue(pair.Key, out partDescription)) {
Contract.Assume(partDescription != null);
if (partDescription.IsRequired || partDescription.IsNondefaultValueSet(messageDictionary.Message)) {
include = true;
if (IsNumeric(partDescription.MemberDeclaredType)) {
type = "number";
} else if (partDescription.MemberDeclaredType.IsAssignableFrom(typeof(bool))) {
type = "boolean";
}
}
} else {
// This is extra data. We always write it out.
include = true;
}
if (include) {
writer.WriteStartElement(pair.Key);
writer.WriteAttributeString("type", type);
writer.WriteString(pair.Value);
writer.WriteEndElement();
}
}
writer.WriteEndElement();
}