本文整理汇总了C#中System.Xml.XmlWriter.WriteQualifiedName方法的典型用法代码示例。如果您正苦于以下问题:C# XmlWriter.WriteQualifiedName方法的具体用法?C# XmlWriter.WriteQualifiedName怎么用?C# XmlWriter.WriteQualifiedName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlWriter
的用法示例。
在下文中一共展示了XmlWriter.WriteQualifiedName方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: WriteEnvelopeBodyFault
private void WriteEnvelopeBodyFault(XmlWriter xmlWriter)
{
if (fault != null)
{
xmlWriter.WriteStartElement("soapenv", "Fault", SoapConstants.SoapEnvelopeNS);
xmlWriter.WriteStartElement("soapenv", "faultcode", SoapConstants.SoapEnvelopeNS);
xmlWriter.WriteQualifiedName(fault.FaultCode.ToString(), SoapConstants.SoapEnvelopeNS);
xmlWriter.WriteEndElement();
xmlWriter.WriteStartElement("soapenv", "faultstring", SoapConstants.SoapEnvelopeNS);
xmlWriter.WriteString(fault.FaultString);
xmlWriter.WriteEndElement();
xmlWriter.WriteEndElement();
}
}
示例2: WriteFaultCodeValue
private static void WriteFaultCodeValue(XmlWriter writer, XmlQualifiedName code, SoapFaultSubCode subcode) {
if (code == null) return;
writer.WriteStartElement(Soap12.Element.FaultCodeValue, Soap12.Namespace);
if (code.Namespace != null && code.Namespace.Length > 0 && writer.LookupPrefix(code.Namespace) == null)
writer.WriteAttributeString("xmlns", "q0", null, code.Namespace);
writer.WriteQualifiedName(code.Name, code.Namespace);
writer.WriteEndElement(); // </value>
if (subcode != null) {
writer.WriteStartElement(Soap12.Element.FaultSubcode, Soap12.Namespace);
WriteFaultCodeValue(writer, subcode.Code, subcode.SubCode);
writer.WriteEndElement(); // </subcode>
}
}
示例3: InvokeMethod
private void InvokeMethod(XmlWriter w, string methodName)
{
byte[] buffer = new byte[10];
switch (methodName)
{
case "WriteStartDocument":
w.WriteStartDocument();
break;
case "WriteStartElement":
w.WriteStartElement("root");
break;
case "WriteEndElement":
w.WriteEndElement();
break;
case "WriteStartAttribute":
w.WriteStartAttribute("attr");
break;
case "WriteEndAttribute":
w.WriteEndAttribute();
break;
case "WriteCData":
w.WriteCData("test");
break;
case "WriteComment":
w.WriteComment("test");
break;
case "WritePI":
w.WriteProcessingInstruction("name", "test");
break;
case "WriteEntityRef":
w.WriteEntityRef("e");
break;
case "WriteCharEntity":
w.WriteCharEntity('c');
break;
case "WriteSurrogateCharEntity":
w.WriteSurrogateCharEntity('\uDC00', '\uDBFF');
break;
case "WriteWhitespace":
w.WriteWhitespace(" ");
break;
case "WriteString":
w.WriteString("foo");
break;
case "WriteChars":
char[] charArray = new char[] { 'a', 'b', 'c', 'd' };
w.WriteChars(charArray, 0, 3);
break;
case "WriteRaw":
w.WriteRaw("<foo>bar</foo>");
break;
case "WriteBase64":
w.WriteBase64(buffer, 0, 9);
break;
case "WriteBinHex":
w.WriteBinHex(buffer, 0, 9);
break;
case "LookupPrefix":
string str = w.LookupPrefix("foo");
break;
case "WriteNmToken":
w.WriteNmToken("foo");
break;
case "WriteName":
w.WriteName("foo");
break;
case "WriteQualifiedName":
w.WriteQualifiedName("foo", "bar");
break;
case "WriteValue":
w.WriteValue(Int32.MaxValue);
break;
case "WriteAttributes":
XmlReader xr1 = ReaderHelper.Create(new StringReader("<root attr='test'/>"));
xr1.Read();
w.WriteAttributes(xr1, false);
break;
case "WriteNodeReader":
XmlReader xr2 = ReaderHelper.Create(new StringReader("<root/>"));
xr2.Read();
w.WriteNode(xr2, false);
break;
case "Flush":
w.Flush();
break;
default:
CError.Equals(false, "Unexpected param in testcase: {0}", methodName);
break;
}
}
示例4: WriteFaultCodeValue
private static void WriteFaultCodeValue(XmlWriter writer, XmlQualifiedName code, SoapFaultSubCode subcode)
{
if (code != null)
{
writer.WriteStartElement("Value", "http://www.w3.org/2003/05/soap-envelope");
if (((code.Namespace != null) && (code.Namespace.Length > 0)) && (writer.LookupPrefix(code.Namespace) == null))
{
writer.WriteAttributeString("xmlns", "q0", null, code.Namespace);
}
writer.WriteQualifiedName(code.Name, code.Namespace);
writer.WriteEndElement();
if (subcode != null)
{
writer.WriteStartElement("Subcode", "http://www.w3.org/2003/05/soap-envelope");
WriteFaultCodeValue(writer, subcode.Code, subcode.SubCode);
writer.WriteEndElement();
}
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:19,代码来源:Soap12ServerProtocolHelper.cs
示例5: WriteFault
internal override void WriteFault(XmlWriter writer, SoapException soapException, HttpStatusCode statusCode)
{
if ((statusCode == HttpStatusCode.InternalServerError) && (soapException != null))
{
SoapServerMessage message = base.ServerProtocol.Message;
writer.WriteStartDocument();
writer.WriteStartElement("soap", "Envelope", "http://schemas.xmlsoap.org/soap/envelope/");
writer.WriteAttributeString("xmlns", "soap", null, "http://schemas.xmlsoap.org/soap/envelope/");
writer.WriteAttributeString("xmlns", "xsi", null, "http://www.w3.org/2001/XMLSchema-instance");
writer.WriteAttributeString("xmlns", "xsd", null, "http://www.w3.org/2001/XMLSchema");
if (base.ServerProtocol.ServerMethod != null)
{
SoapHeaderHandling.WriteHeaders(writer, base.ServerProtocol.ServerMethod.outHeaderSerializer, message.Headers, base.ServerProtocol.ServerMethod.outHeaderMappings, SoapHeaderDirection.Fault, base.ServerProtocol.ServerMethod.use == SoapBindingUse.Encoded, base.ServerType.serviceNamespace, base.ServerType.serviceDefaultIsEncoded, "http://schemas.xmlsoap.org/soap/envelope/");
}
else
{
SoapHeaderHandling.WriteUnknownHeaders(writer, message.Headers, "http://schemas.xmlsoap.org/soap/envelope/");
}
writer.WriteStartElement("Body", "http://schemas.xmlsoap.org/soap/envelope/");
writer.WriteStartElement("Fault", "http://schemas.xmlsoap.org/soap/envelope/");
writer.WriteStartElement("faultcode", "");
XmlQualifiedName name = TranslateFaultCode(soapException.Code);
if (((name.Namespace != null) && (name.Namespace.Length > 0)) && (writer.LookupPrefix(name.Namespace) == null))
{
writer.WriteAttributeString("xmlns", "q0", null, name.Namespace);
}
writer.WriteQualifiedName(name.Name, name.Namespace);
writer.WriteEndElement();
writer.WriteStartElement("faultstring", "");
if ((soapException.Lang != null) && (soapException.Lang.Length != 0))
{
writer.WriteAttributeString("xml", "lang", "http://www.w3.org/XML/1998/namespace", soapException.Lang);
}
writer.WriteString(base.ServerProtocol.GenerateFaultString(soapException));
writer.WriteEndElement();
string actor = soapException.Actor;
if (actor.Length > 0)
{
writer.WriteElementString("faultactor", "", actor);
}
if (!(soapException is SoapHeaderException))
{
if (soapException.Detail == null)
{
writer.WriteStartElement("detail", "");
writer.WriteEndElement();
}
else
{
soapException.Detail.WriteTo(writer);
}
}
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndElement();
writer.Flush();
}
}
开发者ID:pritesh-mandowara-sp,项目名称:DecompliedDotNetLibraries,代码行数:58,代码来源:Soap11ServerProtocolHelper.cs
示例6: WriteFault
internal override void WriteFault(XmlWriter writer, SoapException soapException, HttpStatusCode statusCode) {
if (statusCode != HttpStatusCode.InternalServerError)
return;
if (soapException == null)
return;
SoapServerMessage message = ServerProtocol.Message;
writer.WriteStartDocument();
writer.WriteStartElement(Soap.Prefix, Soap.Element.Envelope, Soap.Namespace);
writer.WriteAttributeString("xmlns", Soap.Prefix, null, Soap.Namespace);
writer.WriteAttributeString("xmlns", "xsi", null, XmlSchema.InstanceNamespace);
writer.WriteAttributeString("xmlns", "xsd", null, XmlSchema.Namespace);
if (ServerProtocol.ServerMethod != null)
SoapHeaderHandling.WriteHeaders(writer, ServerProtocol.ServerMethod.outHeaderSerializer, message.Headers, ServerProtocol.ServerMethod.outHeaderMappings, SoapHeaderDirection.Fault, ServerProtocol.ServerMethod.use == SoapBindingUse.Encoded, ServerType.serviceNamespace, ServerType.serviceDefaultIsEncoded, Soap.Namespace);
else
SoapHeaderHandling.WriteUnknownHeaders(writer, message.Headers, Soap.Namespace);
writer.WriteStartElement(Soap.Element.Body, Soap.Namespace);
writer.WriteStartElement(Soap.Element.Fault, Soap.Namespace);
writer.WriteStartElement(Soap.Element.FaultCode, "");
XmlQualifiedName code = TranslateFaultCode(soapException.Code);
if (code.Namespace != null && code.Namespace.Length > 0 && writer.LookupPrefix(code.Namespace) == null)
writer.WriteAttributeString("xmlns", "q0", null, code.Namespace);
writer.WriteQualifiedName(code.Name, code.Namespace);
writer.WriteEndElement();
// write faultString element with possible "lang" attribute
writer.WriteStartElement(Soap.Element.FaultString, "");
if (soapException.Lang != null && soapException.Lang.Length != 0) {
writer.WriteAttributeString("xml", Soap.Attribute.Lang, Soap.XmlNamespace, soapException.Lang);
}
writer.WriteString(ServerProtocol.GenerateFaultString(soapException));
writer.WriteEndElement();
// Only write an actor element if the actor was specified (it's optional for end-points)
string actor = soapException.Actor;
if (actor.Length > 0)
writer.WriteElementString(Soap.Element.FaultActor, "", actor);
// Only write a FaultDetail element if exception is related to the body (not a header)
if (!(soapException is SoapHeaderException)) {
if (soapException.Detail == null) {
//
writer.WriteStartElement(Soap.Element.FaultDetail, "");
writer.WriteEndElement();
}
else {
soapException.Detail.WriteTo(writer);
}
}
writer.WriteEndElement();
writer.WriteEndElement();
writer.WriteEndElement();
writer.Flush();
}
示例7: WriteTypeQualifier
private void WriteTypeQualifier(XmlWriter writer, ITypeSerializationInfo type)
{
if (type.NamespacePrefix != null)
{
if (writer.LookupPrefix(type.Namespace) != type.NamespacePrefix)
{
writer.WriteAttributeString("xmlns", type.NamespacePrefix, null, type.Namespace);
}
writer.WriteAttributeString(XMLSchemaInstancePrefix, TypeField, XMLSchemaInstanceNamespace,
type.NamespacePrefix + ":" + type.ElementName);
}
else
{
writer.WriteStartAttribute(XMLSchemaInstancePrefix, TypeField, XMLSchemaInstanceNamespace);
writer.WriteQualifiedName(type.ElementName, type.Namespace);
writer.WriteEndAttribute();
}
}
示例8: WriteXml
/// <summary>
/// Serializes this Annotation to XML with the passed in XmlWriter.
/// </summary>
/// <param name="writer">the writer to serialize the Annotation to</param>
/// <exception cref="ArgumentNullException">writer is null</exception>
public void WriteXml(XmlWriter writer)
{
if (writer == null)
{
throw new ArgumentNullException("writer");
}
//fire trace event
EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.SerializeAnnotationBegin);
try
{
if (String.IsNullOrEmpty(writer.LookupPrefix(AnnotationXmlConstants.Namespaces.CoreSchemaNamespace)))
{
writer.WriteAttributeString(AnnotationXmlConstants.Prefixes.XmlnsPrefix, AnnotationXmlConstants.Prefixes.CoreSchemaPrefix, null, AnnotationXmlConstants.Namespaces.CoreSchemaNamespace);
}
if (String.IsNullOrEmpty(writer.LookupPrefix(AnnotationXmlConstants.Namespaces.BaseSchemaNamespace)))
{
writer.WriteAttributeString(AnnotationXmlConstants.Prefixes.XmlnsPrefix, AnnotationXmlConstants.Prefixes.BaseSchemaPrefix, null, AnnotationXmlConstants.Namespaces.BaseSchemaNamespace);
}
if (_typeName == null)
{
throw new InvalidOperationException(SR.Get(SRID.CannotSerializeInvalidInstance));
}
// XmlConvert.ToString is [Obsolete]
#pragma warning disable 0618
writer.WriteAttributeString(AnnotationXmlConstants.Attributes.Id, XmlConvert.ToString(_id));
writer.WriteAttributeString(AnnotationXmlConstants.Attributes.CreationTime, XmlConvert.ToString(_created));
writer.WriteAttributeString(AnnotationXmlConstants.Attributes.LastModificationTime, XmlConvert.ToString(_modified));
#pragma warning restore 0618
writer.WriteStartAttribute(AnnotationXmlConstants.Attributes.TypeName);
writer.WriteQualifiedName(_typeName.Name, _typeName.Namespace);
writer.WriteEndAttribute();
if (_authors != null && _authors.Count > 0)
{
writer.WriteStartElement(AnnotationXmlConstants.Elements.AuthorCollection, AnnotationXmlConstants.Namespaces.CoreSchemaNamespace);
foreach (string author in _authors)
{
if (author != null)
{
writer.WriteElementString(AnnotationXmlConstants.Prefixes.BaseSchemaPrefix, AnnotationXmlConstants.Elements.StringAuthor, AnnotationXmlConstants.Namespaces.BaseSchemaNamespace, author);
}
}
writer.WriteEndElement();
}
if (_anchors != null && _anchors.Count > 0)
{
writer.WriteStartElement(AnnotationXmlConstants.Elements.AnchorCollection, AnnotationXmlConstants.Namespaces.CoreSchemaNamespace);
foreach (AnnotationResource anchor in _anchors)
{
if (anchor != null)
{
ResourceSerializer.Serialize(writer, anchor);
}
}
writer.WriteEndElement();
}
if (_cargos != null && _cargos.Count > 0)
{
writer.WriteStartElement(AnnotationXmlConstants.Elements.CargoCollection, AnnotationXmlConstants.Namespaces.CoreSchemaNamespace);
foreach (AnnotationResource cargo in _cargos)
{
if (cargo != null)
{
ResourceSerializer.Serialize(writer, cargo);
}
}
writer.WriteEndElement();
}
}
finally
{
//fire trace event
EventTrace.EasyTraceEvent(EventTrace.Keyword.KeywordAnnotation, EventTrace.Event.SerializeAnnotationEnd);
}
}