本文整理汇总了C#中System.Xml.XmlDictionaryWriter.WriteNode方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDictionaryWriter.WriteNode方法的具体用法?C# XmlDictionaryWriter.WriteNode怎么用?C# XmlDictionaryWriter.WriteNode使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDictionaryWriter
的用法示例。
在下文中一共展示了XmlDictionaryWriter.WriteNode方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: OnWriteBodyContents
protected override void OnWriteBodyContents (
XmlDictionaryWriter writer)
{
if (reader == null && String.IsNullOrEmpty (xml))
return;
XmlReader r = reader ?? XmlReader.Create (new StringReader (xml));
r.MoveToContent ();
writer.WriteNode (r, false);
}
示例2: OnWriteBodyContents
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
using (XmlReader reader = new XmlTextReader(this.FileName))
{
while (!reader.EOF)
{
writer.WriteNode(reader, false);
}
}
}
示例3: OnWriteAddressHeaderContents
protected override void OnWriteAddressHeaderContents(XmlDictionaryWriter writer)
{
XmlDictionaryReader addressHeaderReader = this.GetAddressHeaderReader();
addressHeaderReader.ReadStartElement();
while (addressHeaderReader.NodeType != XmlNodeType.EndElement)
{
writer.WriteNode(addressHeaderReader, false);
}
addressHeaderReader.ReadEndElement();
addressHeaderReader.Close();
}
示例4: OnWriteHeaderContents
protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion)
{
XmlDictionaryReader headerReader = this.GetHeaderReader();
headerReader.ReadStartElement();
while (headerReader.NodeType != XmlNodeType.EndElement)
{
writer.WriteNode(headerReader, false);
}
headerReader.ReadEndElement();
headerReader.Close();
}
示例5: OnWriteDetailContents
/// <summary>
/// When overridden in a non-abstract derived class, writes the contents of the detail element.
/// </summary>
/// <param name="writer">The <see cref="T:System.Xml.XmlDictionaryWriter"/> used to write the detail element.</param>
protected override void OnWriteDetailContents(XmlDictionaryWriter writer)
{
var prefix = writer.LookupPrefix(this._nameSpace) ?? "web";
using (var reader = this._messageFault.GetReaderAtDetailContents())
{
if ("Error".Equals(reader.LocalName) && string.IsNullOrWhiteSpace(reader.NamespaceURI))
{
writer.WriteStartElement(prefix, "Error", this._nameSpace);
reader.Read();
// ErrorMessage
writer.WriteNode(reader, false);
// ErrorNumber
writer.WriteNode(reader, false);
//
writer.WriteNode(reader, false);
}
}
}
示例6: OnWriteBodyContents
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
using (this.reader)
{
for (XmlNodeType type = this.reader.MoveToContent(); !this.reader.EOF && (type != XmlNodeType.EndElement); type = this.reader.MoveToContent())
{
if (type != XmlNodeType.Element)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(System.ServiceModel.SR.GetString("InvalidReaderPositionOnCreateMessage"), "reader"));
}
writer.WriteNode(this.reader, false);
}
}
}
示例7: OnWriteBodyContents
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
if (!this.isEmpty)
{
using (XmlDictionaryReader reader = this.OnGetReaderAtBodyContents())
{
if ((reader.ReadState != System.Xml.ReadState.Error) && (reader.ReadState != System.Xml.ReadState.Closed))
{
goto Label_005E;
}
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new InvalidOperationException(System.ServiceModel.SR.GetString("MessageBodyReaderInvalidReadState", new object[] { reader.ReadState.ToString() })));
Label_0056:
writer.WriteNode(reader, false);
Label_005E:
if ((reader.NodeType != XmlNodeType.EndElement) && !reader.EOF)
{
goto Label_0056;
}
base.ReadFromBodyContentsToEnd(reader);
}
}
}
示例8: WriteContentsTo10
void WriteContentsTo10(XmlDictionaryWriter writer)
{
// Address
writer.WriteStartElement(XD.AddressingDictionary.Address, XD.Addressing10Dictionary.Namespace);
if (isAnonymous)
{
writer.WriteString(XD.Addressing10Dictionary.Anonymous);
}
else if (isNone)
{
writer.WriteString(XD.Addressing10Dictionary.NoneAddress);
}
else
{
writer.WriteString(this.Uri.AbsoluteUri);
}
writer.WriteEndElement();
// Headers
if (this.headers != null && this.headers.Count > 0)
{
writer.WriteStartElement(XD.AddressingDictionary.ReferenceParameters, XD.Addressing10Dictionary.Namespace);
this.headers.WriteContentsTo(writer);
writer.WriteEndElement();
}
// Metadata
if (this.metadataSection >= 0)
{
XmlDictionaryReader reader = GetReaderAtSection(this.buffer, metadataSection);
writer.WriteStartElement(XD.Addressing10Dictionary.Metadata, XD.Addressing10Dictionary.Namespace);
Copy(writer, reader);
writer.WriteEndElement();
}
// EndpointIdentity
if (this.Identity != null)
{
this.Identity.WriteTo(writer);
}
// Extensions
if (this.extensionSection >= 0)
{
XmlDictionaryReader reader = GetReaderAtSection(this.buffer, this.extensionSection);
while (reader.IsStartElement())
{
if (reader.NamespaceURI == AddressingVersion.WSAddressing10.Namespace)
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateXmlException(reader, SR.GetString(SR.AddressingExtensionInBadNS, reader.LocalName, reader.NamespaceURI)));
}
writer.WriteNode(reader, true);
}
}
}
示例9: WriteTokenCore
public override void WriteTokenCore(XmlDictionaryWriter writer, SecurityToken token)
{
BufferedGenericXmlSecurityToken bufferedXmlToken = token as BufferedGenericXmlSecurityToken;
if (bufferedXmlToken != null && bufferedXmlToken.TokenXmlBuffer != null)
{
using (XmlDictionaryReader reader = bufferedXmlToken.TokenXmlBuffer.GetReader(0))
{
writer.WriteNode(reader, false);
}
}
else
{
GenericXmlSecurityToken xmlToken = (GenericXmlSecurityToken)token;
xmlToken.TokenXml.WriteTo(writer);
}
}
示例10: OnBodyToString
protected override void OnBodyToString(XmlDictionaryWriter writer)
{
using (XmlDictionaryReader reader = GetBufferedReaderAtBody())
{
while (reader.NodeType != XmlNodeType.EndElement)
{
writer.WriteNode(reader, false);
}
}
}
示例11: WriteNodeToWriter
public static void WriteNodeToWriter(byte[] buffer, XmlDictionaryWriter writer)
{
using (XmlDictionaryReader reader = Utility.CreateReader(buffer))
{
writer.WriteNode((XmlReader)reader, false);
}
}
示例12: OnWriteHeaderContents
protected override void OnWriteHeaderContents(XmlDictionaryWriter writer, MessageVersion messageVersion)
{
XmlDictionaryReader reader = GetHeaderReader();
reader.ReadStartElement();
while (reader.NodeType != XmlNodeType.EndElement)
writer.WriteNode(reader, false);
reader.ReadEndElement();
reader.Dispose();
}
示例13: WriteObjectContent
public override void WriteObjectContent(XmlDictionaryWriter writer, object graph)
{
if (writer == null) throw new ArgumentNullException("writer");
if (writer.WriteState != WriteState.Element)
throw new SerializationException(string.Format("WriteState '{0}' not valid. Caller must write start element before serializing in contentOnly mode.",
writer.WriteState));
using (MemoryStream memoryStream = new MemoryStream())
{
using (XmlDictionaryWriter bufferWriter = XmlDictionaryWriter.CreateTextWriter(memoryStream, Encoding.UTF8))
{
serializer.Serialize(bufferWriter, graph);
bufferWriter.Flush();
memoryStream.Position = 0;
using (XmlReader reader = new XmlTextReader(memoryStream))
{
reader.MoveToContent();
writer.WriteAttributes(reader, false);
if (reader.Read()) // move off start node (we want to skip it)
{
while (reader.NodeType != XmlNodeType.EndElement) // also skip end node.
writer.WriteNode(reader, false); // this will take us to the start of the next child node, or the end node.
reader.ReadEndElement(); // not necessary, but clean
}
}
}
}
}
示例14: OnBodyToString
protected override void OnBodyToString(XmlDictionaryWriter writer)
{
using (XmlDictionaryReader reader = this.GetBufferedReaderAtBody())
{
if (this.Version == MessageVersion.None)
{
writer.WriteNode(reader, false);
}
else if (!reader.IsEmptyElement)
{
reader.ReadStartElement();
while (reader.NodeType != XmlNodeType.EndElement)
{
writer.WriteNode(reader, false);
}
}
}
}
示例15: AddReference
public void AddReference(string headerId, XmlDictionaryReader reader, XmlDictionaryWriter writer)
{
HashStream hashStream = this.TakeHashStream();
writer.StartCanonicalization(hashStream, false, this.InclusivePrefixes);
// The reader must be positioned on the start element of the header / body we want to canonicalize
writer.WriteNode(reader, false);
writer.EndCanonicalization();
writer.Flush();
// Add a reference for this block
this.AddReference(headerId, hashStream.FlushHashAndGetValue());
}