当前位置: 首页>>代码示例>>C#>>正文


C# XmlWriter.LookupPrefix方法代码示例

本文整理汇总了C#中System.Xml.XmlWriter.LookupPrefix方法的典型用法代码示例。如果您正苦于以下问题:C# XmlWriter.LookupPrefix方法的具体用法?C# XmlWriter.LookupPrefix怎么用?C# XmlWriter.LookupPrefix使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在System.Xml.XmlWriter的用法示例。


在下文中一共展示了XmlWriter.LookupPrefix方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: WriteXmlSchemaType

 public override void WriteXmlSchemaType(XmlWriter xw, string xmlns)
 {
     xw.WriteStartElement("complexType", XmlSchemaUtil.SCHEMA_NS);
     if (Name != null) xw.WriteAttributeString("name", Name);
     xw.WriteStartElement("sequence", XmlSchemaUtil.SCHEMA_NS);
     foreach (MemberDef member in Members)
     {
         xw.WriteStartElement("element", XmlSchemaUtil.SCHEMA_NS);
         xw.WriteAttributeString("name", member.Name);
         TypeDef td = ParentTypeSet.GetTypeDef(member.TypeName);
         if (td.IsSimpleType)
         {
             xw.WriteAttributeString("type", "xs:" + td.Name);
             if (member.IsRequired)
                 xw.WriteAttributeString("nillable", "false");
         }
         else
         {
             if (string.IsNullOrEmpty(xmlns))
                 xw.WriteAttributeString("type", td.Name);
             else
             {
                 string prf = xw.LookupPrefix(xmlns);
                 xw.WriteAttributeString("type", string.Format("{0}:{1}", prf, td.Name));
             }
         }
         xw.WriteAttributeString("minOccurs", member.IsRequired ? "1" : "0");
         xw.WriteAttributeString("maxOccurs", member.IsArray ? "unbounded" : "1");
         xw.WriteEndElement();
     }
     xw.WriteEndElement();
     xw.WriteEndElement();
 }
开发者ID:yonglehou,项目名称:NGinnBPM,代码行数:33,代码来源:StructDef.cs

示例2: ToQName

 internal static string ToQName(this PrintSchemaName self, XmlWriter writer)
 {
     var prefix = writer.LookupPrefix(self.NamespaceName);
     if (prefix == null)
     {
         throw new InternalException($"Namespace declaration not found: {self.Namespace}");
     }
     else if (prefix == string.Empty)
     {
         return self.LocalName;
     }
     else
     {
         return prefix + ":" + self.LocalName;
     }
 }
开发者ID:kei10in,项目名称:KipSharp,代码行数:16,代码来源:XmlUtils.cs

示例3: WriteTo

        /// <summary>
        /// Saves the current node to the specified XmlWriter. 
        /// </summary>
        /// <param name="xmlWriter">
        /// The XmlWriter to which to save the current node.
        /// </param>
        public override void WriteTo(XmlWriter xmlWriter)
        {
            if (xmlWriter == null)
            {
                throw new ArgumentNullException("xmlWriter");
            }

            if (this.XmlParsed)
            {
                //check the namespace mapping defined in this node first. because till now xmlWriter don't know the mapping defined in the current node.
                string prefix = LookupNamespaceLocal(this.NamespaceUri);
                
                //if not defined in the current node, try the xmlWriter
                if (this.Parent != null && string.IsNullOrEmpty(prefix))
                {
                    prefix = xmlWriter.LookupPrefix(this.NamespaceUri);
                }
                //if xmlWriter didn't find it, it means the node is constructed by user and is not in the tree yet
                //in this case, we use the predefined prefix
                if (string.IsNullOrEmpty(prefix))
                {
                    prefix = NamespaceIdMap.GetNamespacePrefix(this.NamespaceId);
                }

                xmlWriter.WriteStartElement(prefix, this.LocalName, this.NamespaceUri);
                // fix bug #225919, write out all namespace into to root 
                WriteNamespaceAtributes(xmlWriter);
                this.WriteAttributesTo(xmlWriter);

                if (this.HasChildren || !string.IsNullOrEmpty(this.InnerText))
                {
                    this.WriteContentTo(xmlWriter);
                    xmlWriter.WriteFullEndElement();
                }
                else
                {
                    xmlWriter.WriteEndElement();
                }
            }
            else
            {
                xmlWriter.WriteRaw(this.RawOuterXml);
            }
        }
开发者ID:eriawan,项目名称:Open-XML-SDK,代码行数:50,代码来源:OpenXmlPartRootElement.cs

示例4: WriteContentTo

		void WriteContentTo (XmlWriter writer)
		{
			if (writer.LookupPrefix (Namespaces.Atom10) == null)
				writer.WriteAttributeString ("xmlns", "a10", Namespaces.Xmlns, Namespaces.Atom10);
			if (writer.LookupPrefix (Version) == null)
				writer.WriteAttributeString ("xmlns", "app", Namespaces.Xmlns, Version);

			// xml:lang, xml:base, workspace*
			if (Document.Language != null)
				writer.WriteAttributeString ("xml", "lang", Namespaces.Xml, Document.Language);
			if (Document.BaseUri != null)
				writer.WriteAttributeString ("xml", "base", Namespaces.Xml, Document.BaseUri.ToString ());

			Document.WriteAttributeExtensions (writer, Version);
			Document.WriteElementExtensions (writer, Version);

			foreach (var ws in Document.Workspaces) {
				writer.WriteStartElement ("app", "workspace", Version);

				// xml:base, title, collection*
				if (ws.BaseUri != null)
					writer.WriteAttributeString ("xml", "base", Namespaces.Xml, ws.BaseUri.ToString ());

				ws.WriteAttributeExtensions (writer, Version);
				ws.WriteElementExtensions (writer, Version);

				if (ws.Title != null)
					ws.Title.WriteTo (writer, "title", Namespaces.Atom10);
				foreach (var rc in ws.Collections) {
					writer.WriteStartElement ("app", "collection", Version);

					// accept*, xml:base, category, @href, title
					if (rc.BaseUri != null)
						writer.WriteAttributeString ("xml", "base", Namespaces.Xml, rc.BaseUri.ToString ());
					if (rc.Link != null)
						writer.WriteAttributeString ("href", rc.Link.ToString ());

					rc.WriteAttributeExtensions (writer, Version);

					if (rc.Title != null)
						rc.Title.WriteTo (writer, "title", Namespaces.Atom10);
					foreach (var s in rc.Accepts) {
						writer.WriteStartElement ("app", "accept", Version);
						writer.WriteString (s);
						writer.WriteEndElement ();
					}
					foreach (var cat in rc.Categories)
						cat.Save (writer);

					writer.WriteEndElement ();
				}
				writer.WriteEndElement ();
			}
		}
开发者ID:nickchal,项目名称:pash,代码行数:54,代码来源:AtomPub10ServiceDocumentFormatter.cs

示例5: WriteTo

        /// <summary>
        /// Saves the current <see cref="AtomTextConstruct"/> to the specified <see cref="XmlWriter"/>.
        /// </summary>
        /// <param name="writer">The <see cref="XmlWriter"/> to which you want to save.</param>
        /// <param name="elementName">The local name of the text construct being written.</param>
        /// <exception cref="ArgumentNullException">The <paramref name="writer"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="elementName"/> is a null reference (Nothing in Visual Basic).</exception>
        /// <exception cref="ArgumentNullException">The <paramref name="elementName"/> is an empty string.</exception>
        public void WriteTo(XmlWriter writer, string elementName)
        {
            //------------------------------------------------------------
            //	Validate parameter
            //------------------------------------------------------------
            Guard.ArgumentNotNull(writer, "writer");
            Guard.ArgumentNotNullOrEmptyString(elementName, "elementName");

            //------------------------------------------------------------
            //	Write XML representation of the current instance
            //------------------------------------------------------------
            writer.WriteStartElement(elementName, AtomUtility.AtomNamespace);
            AtomUtility.WriteCommonObjectAttributes(this, writer);

            if (this.TextType == AtomTextConstructType.Xhtml && String.IsNullOrEmpty(writer.LookupPrefix(AtomUtility.XhtmlNamespace)))
            {
                writer.WriteAttributeString("xmlns", "xhtml", null, AtomUtility.XhtmlNamespace);
            }

            if (this.TextType != AtomTextConstructType.None)
            {
                writer.WriteAttributeString("type", AtomTextConstruct.ConstructTypeAsString(this.TextType));
            }

            if (this.TextType == AtomTextConstructType.Xhtml)
            {
                writer.WriteStartElement("div", AtomUtility.XhtmlNamespace);
                writer.WriteString(this.Content);
                writer.WriteEndElement();
            }
            else
            {
                writer.WriteString(this.Content);
            }

            //------------------------------------------------------------
            //	Write the syndication extensions of the current instance
            //------------------------------------------------------------
            SyndicationExtensionAdapter.WriteExtensionsTo(this.Extensions, writer);

            writer.WriteEndElement();
        }
开发者ID:Jiyuu,项目名称:Argotic,代码行数:50,代码来源:AtomTextConstruct.cs

示例6: AddOtherNamespaces

 /// <summary>
 /// add the spreadsheet NS
 /// </summary>
 /// <param name="writer">The XmlWrite, where we want to add default namespaces to</param>
 protected override void AddOtherNamespaces(XmlWriter writer)
 {
     base.AddOtherNamespaces(writer);
     if (writer == null)
     {
         throw new ArgumentNullException("writer"); 
     }
     string strPrefix = writer.LookupPrefix(GDataSpreadsheetsNameTable.NSGSpreadsheets);
     if (strPrefix == null)
     {
         writer.WriteAttributeString("xmlns", GDataSpreadsheetsNameTable.Prefix, null, GDataSpreadsheetsNameTable.NSGSpreadsheets);
     }
 }
开发者ID:Zelxin,项目名称:RPiKeg,代码行数:17,代码来源:cellentry.cs

示例7: WriteStartElement

        /// <summary>
        /// Starts writing an element for the given DomNode</summary>
        /// <param name="node">DomNode to write</param>
        /// <param name="writer">The XML writer. See <see cref="T:System.Xml.XmlWriter"/></param>
        protected void WriteStartElement(DomNode node, XmlWriter writer)
        {
            // It's possible to create DomNodes with no ChildInfo, and if the DomNode is never
            //  parented, then its ChildInfo property will still be null. We could try to search
            //  for a compatible root element in the m_typeCollection, but that's more code.
            if (node.ChildInfo == null)
                throw new InvalidOperationException(
                    "Please check your document's creation method to ensure that the root DomNode's" +
                    " constructor was given a ChildInfo.");
            // writes the start of an element
            m_elementNS = m_typeCollection.TargetNamespace;
            int index = node.ChildInfo.Type.Name.LastIndexOf(':');
            if (index >= 0)
                m_elementNS = node.ChildInfo.Type.Name.Substring(0, index);

            m_elementPrefix = string.Empty;

            // is this the root DomNode (the one passed to Write)?
            if (IsRootNode(node))
            {
                m_elementPrefix = m_typeCollection.GetPrefix(m_elementNS);
                if (m_elementPrefix == null)
                    m_elementPrefix = GeneratePrefix(m_elementNS);

                writer.WriteStartElement(m_elementPrefix, node.ChildInfo.Name, m_elementNS);

                // define the xsi namespace
                writer.WriteAttributeString("xmlns", "xsi", null, XmlSchema.InstanceNamespace);

                // define schema namespaces
                foreach (XmlQualifiedName name in m_typeCollection.Namespaces)
                    if (name.Name != m_elementPrefix) // don't redefine the element namespace
                        writer.WriteAttributeString("xmlns", name.Name, null, name.Namespace);
            }
            else
            {
                ChildInfo actualChildInfo = node.ChildInfo;

                var substitutionGroupRule = node.ChildInfo.Rules.OfType<SubstitutionGroupChildRule>().FirstOrDefault();
                if (substitutionGroupRule != null)
                {
                    var substituteChildInfo = substitutionGroupRule.Substitutions.FirstOrDefault(x => x.Type == node.Type);
                    if (substituteChildInfo == null)
                    {
                        throw new InvalidOperationException("No suitable Substitution Group found for node " + node);
                    }

                    actualChildInfo = substituteChildInfo;
                    m_elementNS = m_typeCollection.TargetNamespace;

                    index = substituteChildInfo.Type.Name.LastIndexOf(':');
                    if (index >= 0)
                        m_elementNS = substituteChildInfo.Type.Name.Substring(0, index);

                    // It is possible that an element of this namspace has not
                    // yet been written.  If the lookup fails then get the prefix from
                    // the type collection
                    m_elementPrefix = writer.LookupPrefix(m_elementNS);
                    if (m_elementPrefix == null)
                    {
                        m_elementPrefix = m_typeCollection.GetPrefix(m_elementNS);
                    }

                }
                else
                {
                    // not the root, so all schema namespaces have been defined
                    m_elementPrefix = writer.LookupPrefix(m_elementNS);
                }

                if (m_elementPrefix == null)
                    m_elementPrefix = GeneratePrefix(m_elementNS);

                writer.WriteStartElement(m_elementPrefix, actualChildInfo.Name, m_elementNS);
            }
        }
开发者ID:vincenthamm,项目名称:ATF,代码行数:80,代码来源:DomXmlWriter.cs

示例8: 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;
     }
 }
开发者ID:johnhhm,项目名称:corefx,代码行数:90,代码来源:CommonTests.cs

示例9: 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>
     }
 }
开发者ID:iskiselev,项目名称:JSIL.NetFramework,代码行数:13,代码来源:Soap12ServerProtocol.cs

示例10: WriteXml

        /// <summary>
        ///     Writes the internal data for this ContentLocator to the writer.  This 
        ///     method is used by an XmlSerializer to serialize a ContentLocator.  Don't 
        ///     use this method directly, to serialize a ContentLocator to Xml, use an 
        ///     XmlSerializer.
        /// </summary>
        /// <param name="writer">the writer to write internal data to</param>
        /// <exception cref="ArgumentNullException">writer is null</exception>
        public void WriteXml(XmlWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            string prefix = writer.LookupPrefix(AnnotationXmlConstants.Namespaces.CoreSchemaNamespace);
            if (prefix == null)
            {
                writer.WriteAttributeString(AnnotationXmlConstants.Prefixes.XmlnsPrefix, AnnotationXmlConstants.Prefixes.CoreSchemaPrefix, null, AnnotationXmlConstants.Namespaces.CoreSchemaNamespace);
            }
            prefix = writer.LookupPrefix(AnnotationXmlConstants.Namespaces.BaseSchemaNamespace);
            if (prefix == null)
            {
                writer.WriteAttributeString(AnnotationXmlConstants.Prefixes.XmlnsPrefix, AnnotationXmlConstants.Prefixes.BaseSchemaPrefix, null, AnnotationXmlConstants.Namespaces.BaseSchemaNamespace);
            }

            // Write each ContentLocatorPart as its own element
            foreach (ContentLocatorPart part in _parts)
            {
                prefix = writer.LookupPrefix(part.PartType.Namespace);
                if (String.IsNullOrEmpty(prefix))
                {
                    prefix = "tmp";                    
                }

                // ContentLocatorParts cannot write themselves out becuase the element
                // name is based on the part's type.  The ContentLocatorPart instance
                // has no way (through normal serialization) to change the element
                // name it writes out at runtime.
                writer.WriteStartElement(prefix, part.PartType.Name, part.PartType.Namespace);

                // Each name/value pair for the ContentLocatorPart becomes an attribute
                foreach (KeyValuePair<string, string> pair in part.NameValuePairs)
                {
                    writer.WriteStartElement(AnnotationXmlConstants.Elements.Item, AnnotationXmlConstants.Namespaces.CoreSchemaNamespace);
                    writer.WriteAttributeString(AnnotationXmlConstants.Attributes.ItemName, pair.Key);
                    writer.WriteAttributeString(AnnotationXmlConstants.Attributes.ItemValue, pair.Value);
                    writer.WriteEndElement();
                }

                writer.WriteEndElement();
            }
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:53,代码来源:LocatorPartList.cs

示例11: 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();
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:56,代码来源:Soap11ServerProtocol.cs

示例12: WriteAuthorityBinding

        /// <summary>
        /// Serialize a SamlAuthorityBinding.
        /// </summary>
        /// <param name="writer">XmlWriter to serialize the SamlAuthorityBinding</param>
        /// <param name="authorityBinding">SamlAuthoriyBinding to be serialized.</param>
        protected virtual void WriteAuthorityBinding(XmlWriter writer, SamlAuthorityBinding authorityBinding)
        {
            if (writer == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("writer");
            }

            if (authorityBinding == null)
            {
                throw DiagnosticUtility.ExceptionUtility.ThrowHelperArgumentNull("statement");
            }

            writer.WriteStartElement(SamlConstants.Prefix, SamlConstants.ElementNames.AuthorityBinding, SamlConstants.Namespace);

            string prefix = null;
            if (!string.IsNullOrEmpty(authorityBinding.AuthorityKind.Namespace))
            {
                writer.WriteAttributeString(String.Empty, SamlConstants.AttributeNames.NamespaceAttributePrefix, null, authorityBinding.AuthorityKind.Namespace);
                prefix = writer.LookupPrefix(authorityBinding.AuthorityKind.Namespace);
            }

            writer.WriteStartAttribute(SamlConstants.AttributeNames.AuthorityKind, null);
            if (string.IsNullOrEmpty(prefix))
            {
                writer.WriteString(authorityBinding.AuthorityKind.Name);
            }
            else
            {
                writer.WriteString(prefix + ":" + authorityBinding.AuthorityKind.Name);
            }
            writer.WriteEndAttribute();

            writer.WriteAttributeString(SamlConstants.AttributeNames.Location, null, authorityBinding.Location);

            writer.WriteAttributeString(SamlConstants.AttributeNames.Binding, null, authorityBinding.Binding);

            writer.WriteEndElement();
        }
开发者ID:krytht,项目名称:DotNetReferenceSource,代码行数:43,代码来源:SamlSecurityTokenHandler.cs

示例13: WriteTo

 public override void WriteTo(XmlWriter w)
 {
     string prefix = this.Prefix;
     if (!string.IsNullOrEmpty(this.NamespaceURI))
         prefix = w.LookupPrefix(this.NamespaceURI) ?? this.Prefix;
     w.WriteStartElement(prefix, this.LocalName, this.NamespaceURI);
     if (this.HasAttributes)
     {
         XmlAttributePreservingWriter preservingWriter = w as XmlAttributePreservingWriter;
         if (preservingWriter == null || this.preservationDict == null)
             this.WriteAttributesTo(w);
         else
             this.WritePreservedAttributesTo(preservingWriter);
     }
     if (this.IsEmpty)
     {
         w.WriteEndElement();
     }
     else
     {
         this.WriteContentTo(w);
         w.WriteFullEndElement();
     }
 }
开发者ID:micahlmartin,项目名称:XmlTransformer,代码行数:24,代码来源:XmlFileInfoDocument.cs

示例14: 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();
     }
 }
开发者ID:NMFCode,项目名称:NMF,代码行数:18,代码来源:XmiSerializer.cs

示例15: WriteXml

        /// <summary>
        ///     Writes the internal data for this ContentLocatorGroup to the writer.  This method
        ///     is used by an XmlSerializer to serialize a ContentLocatorGroup.  To serialize a
        ///     ContentLocatorGroup to Xml, use an XmlSerializer.
        /// </summary>
        /// <param name="writer">the writer to write internal data to</param>
        /// <exception cref="ArgumentNullException">writer is null</exception>
        public void WriteXml(XmlWriter writer)
        {
            if (writer == null)
            {
                throw new ArgumentNullException("writer");
            }

            string prefix = writer.LookupPrefix(AnnotationXmlConstants.Namespaces.CoreSchemaNamespace);
            if (prefix == null)
            {
                writer.WriteAttributeString(AnnotationXmlConstants.Prefixes.XmlnsPrefix, AnnotationXmlConstants.Prefixes.CoreSchemaPrefix, null, AnnotationXmlConstants.Namespaces.CoreSchemaNamespace);
            }

            foreach (ContentLocatorBase locator in _locators)
            {
                if (locator != null)
                {
                    AnnotationResource.ListSerializer.Serialize(writer, locator);
                }
            }            
        }
开发者ID:JianwenSun,项目名称:cc,代码行数:28,代码来源:LocatorGroup.cs


注:本文中的System.Xml.XmlWriter.LookupPrefix方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。