本文整理汇总了C#中System.Xml.XmlDictionaryWriter.WriteAttributes方法的典型用法代码示例。如果您正苦于以下问题:C# XmlDictionaryWriter.WriteAttributes方法的具体用法?C# XmlDictionaryWriter.WriteAttributes怎么用?C# XmlDictionaryWriter.WriteAttributes使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlDictionaryWriter
的用法示例。
在下文中一共展示了XmlDictionaryWriter.WriteAttributes方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: 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();
}
示例2: OnWriteStartHeader
protected override void OnWriteStartHeader(XmlDictionaryWriter writer, MessageVersion messageVersion)
{
if (!this.IsMessageVersionSupported(messageVersion))
{
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(System.ServiceModel.SR.GetString("MessageHeaderVersionNotSupported", new object[] { base.GetType().FullName, messageVersion.ToString() }), "version"));
}
XmlDictionaryReader headerReader = this.GetHeaderReader();
writer.WriteStartElement(headerReader.Prefix, headerReader.LocalName, headerReader.NamespaceURI);
writer.WriteAttributes(headerReader, false);
headerReader.Close();
}
示例3: OnWriteStartBody
protected override void OnWriteStartBody(XmlDictionaryWriter writer)
{
if (this.state == BodyState.Created)
{
this.InnerMessage.WriteStartBody(writer);
return;
}
XmlDictionaryReader reader = CreateFullBodyReader();
reader.MoveToContent();
writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
writer.WriteAttributes(reader, false);
reader.Close();
}
示例4: OnWriteBodyContents
protected override void OnWriteBodyContents(XmlDictionaryWriter writer)
{
XmlDictionaryReader reader = this.originalMessage.GetReaderAtBodyContents();
// Write root StartElement
writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
writer.WriteAttributes(reader, true);
reader.ReadStartElement();
// Write QueryResult StartElement
writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
writer.WriteAttributes(reader, true);
// Write QueryResult content
string nodeName = reader.LocalName;
reader.Read();
while (reader.NodeType != XmlNodeType.EndElement || reader.Name != nodeName)
{
XmlReader subtree = reader.ReadSubtree();
writer.WriteNode(subtree, false);
reader.ReadEndElement();
}
// Insert metadata start
writer.WriteStartElement("Metadata");
writer.WriteAttributeString("type", "array");
// This two foreach loops are to ensure we write the return entity of the query first, then all the rest.
// This is a requirement of the RIA/JS client side implementation. If modifying this, client side needs update too.
foreach (ServiceMetadataGenerator.TypeMetadata map in ServiceMetadataGenerator.EntitiesMetadata)
{
if (map.Name == this.entityTypeName)
{
writer.WriteStartElement("item");
writer.WriteAttributeString("type", "object");
map.WriteJson(writer);
writer.WriteEndElement();
break;
}
}
foreach (ServiceMetadataGenerator.TypeMetadata map in ServiceMetadataGenerator.EntitiesMetadata)
{
if (map.Name != this.entityTypeName)
{
writer.WriteStartElement("item");
writer.WriteAttributeString("type", "object");
map.WriteJson(writer);
writer.WriteEndElement();
}
}
writer.WriteEndElement();
// Insert metadata end
// Close QueryResult
writer.WriteEndElement();
// Close root
writer.WriteEndElement();
}
示例5: OnWriteStartHeader
protected override void OnWriteStartHeader(XmlDictionaryWriter writer, MessageVersion messageVersion)
{
if (!IsMessageVersionSupported(messageVersion))
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(new ArgumentException(SR.Format(SR.MessageHeaderVersionNotSupported, this.GetType().FullName, messageVersion.ToString()), "version"));
XmlDictionaryReader reader = GetHeaderReader();
writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
writer.WriteAttributes(reader, false);
reader.Dispose();
}
示例6: 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
}
}
}
}
}
示例7: OnWriteStartBody
protected override void OnWriteStartBody(XmlDictionaryWriter writer)
{
if (this.startBodyFragment != null || this.fullBodyFragment != null)
{
WriteStartInnerMessageWithId(writer);
return;
}
switch (this.state)
{
case BodyState.Created:
case BodyState.Encrypted:
this.InnerMessage.WriteStartBody(writer);
return;
case BodyState.Signed:
case BodyState.EncryptedThenSigned:
XmlDictionaryReader reader = fullBodyBuffer.GetReader(0);
writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
writer.WriteAttributes(reader, false);
reader.Close();
return;
case BodyState.SignedThenEncrypted:
writer.WriteStartElement(this.bodyPrefix, XD.MessageDictionary.Body, this.Version.Envelope.DictionaryNamespace);
if (this.bodyAttributes != null)
{
XmlAttributeHolder.WriteAttributes(this.bodyAttributes, writer);
}
return;
default:
throw DiagnosticUtility.ExceptionUtility.ThrowHelperError(CreateBadStateException("OnWriteStartBody"));
}
}
示例8: OnWriteStartHeaders
protected override void OnWriteStartHeaders(XmlDictionaryWriter writer)
{
using (XmlDictionaryReader reader = this.GetMessageReader())
{
reader.MoveToContent();
EnvelopeVersion envelope = this.Version.Envelope;
reader.Read();
if (ReceivedMessage.HasHeaderElement(reader, envelope))
{
writer.WriteStartElement(reader.Prefix, "Header", envelope.Namespace);
writer.WriteAttributes(reader, false);
}
else
{
writer.WriteStartElement("s", "Header", envelope.Namespace);
}
}
}
示例9: OnWriteStartEnvelope
protected override void OnWriteStartEnvelope(XmlDictionaryWriter writer)
{
using (XmlDictionaryReader reader = this.GetMessageReader())
{
reader.MoveToContent();
EnvelopeVersion envelope = this.Version.Envelope;
writer.WriteStartElement(reader.Prefix, "Envelope", envelope.Namespace);
writer.WriteAttributes(reader, false);
}
}
示例10: OnWriteStartBody
protected override void OnWriteStartBody(XmlDictionaryWriter writer)
{
using (XmlDictionaryReader reader = this.GetBufferedReaderAtBody())
{
writer.WriteStartElement(reader.Prefix, "Body", this.Version.Envelope.Namespace);
writer.WriteAttributes(reader, false);
}
}
示例11: OnWriteStartBody
protected override void OnWriteStartBody(XmlDictionaryWriter writer)
{
if ((this.startBodyFragment != null) || (this.fullBodyFragment != null))
{
this.WriteStartInnerMessageWithId(writer);
}
else
{
switch (this.state)
{
case BodyState.Created:
case BodyState.Encrypted:
base.InnerMessage.WriteStartBody(writer);
return;
case BodyState.Signed:
case BodyState.EncryptedThenSigned:
{
XmlDictionaryReader reader = this.fullBodyBuffer.GetReader(0);
writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
writer.WriteAttributes(reader, false);
reader.Close();
return;
}
case BodyState.SignedThenEncrypted:
writer.WriteStartElement(this.bodyPrefix, System.ServiceModel.XD.MessageDictionary.Body, this.Version.Envelope.DictionaryNamespace);
if (this.bodyAttributes != null)
{
System.IdentityModel.XmlAttributeHolder.WriteAttributes(this.bodyAttributes, writer);
}
return;
}
throw System.ServiceModel.DiagnosticUtility.ExceptionUtility.ThrowHelperError(this.CreateBadStateException("OnWriteStartBody"));
}
}
示例12: OnWriteStartBody
protected override void OnWriteStartBody(XmlDictionaryWriter writer)
{
switch (this.state)
{
case BodyState.Created:
this.InnerMessage.WriteStartBody(writer);
return;
case BodyState.Signed:
using (XmlDictionaryReader reader = Utility.CreateReader(this.fullBodyBuffer))
{
reader.MoveToStartElement();
writer.WriteStartElement(reader.Prefix, reader.LocalName, reader.NamespaceURI);
writer.WriteAttributes(reader, false);
}
return;
default:
throw new ArgumentException("Can't write the message because it is in a bad or unknown state");
}
}
示例13: OnWriteHeaderAttributes
/// <summary>
/// Writes header attributes.
/// </summary>
/// <param name="writer">The writer.</param>
/// <param name="messageVersion">The message version.</param>
/// <exception cref="System.ArgumentNullException">
/// writer
/// or
/// messageVersion
/// </exception>
/// <exception cref="ArgumentNullException">The <paramref name="writer"/> parameter is null.</exception>
/// <exception cref="ArgumentNullException">The <paramref name="messageVersion"/> parameter is null.</exception>
protected void OnWriteHeaderAttributes(XmlDictionaryWriter writer, MessageVersion messageVersion)
{
if (writer == null)
throw new ArgumentNullException("writer");
if (messageVersion == null)
throw new ArgumentNullException("messageVersion");
WriteHeaderAttributes(writer, messageVersion);
using (var xmlNodeReader = new XmlNodeReader(_headerValue))
{
using (var reader = XmlDictionaryReader.CreateDictionaryReader(xmlNodeReader))
{
reader.MoveToContent();
writer.WriteAttributes(reader, false);
}
}
}