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


C# XmlNamespaceManager.PushScope方法代码示例

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


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

示例1: GetNsMgr

 private static XmlNamespaceManager GetNsMgr(string csprojFile)
 {
     XmlNamespaceManager nsmgr = new XmlNamespaceManager(new XmlTextReader(csprojFile).NameTable);
     nsmgr.AddNamespace(Constants.MSBUILD, "http://schemas.microsoft.com/developer/msbuild/2003");
     nsmgr.PushScope();
     return nsmgr;
 }
开发者ID:kinow,项目名称:objectified-solutions,代码行数:7,代码来源:CSProjFileParser.cs

示例2: PushParentNamespaces

 private void PushParentNamespaces(IXmlNode node, XmlNamespaceManager manager)
 {
   List<IXmlNode> list = (List<IXmlNode>) null;
   IXmlNode xmlNode1 = node;
   while ((xmlNode1 = xmlNode1.ParentNode) != null)
   {
     if (xmlNode1.NodeType == XmlNodeType.Element)
     {
       if (list == null)
         list = new List<IXmlNode>();
       list.Add(xmlNode1);
     }
   }
   if (list == null)
     return;
   list.Reverse();
   foreach (IXmlNode xmlNode2 in list)
   {
     manager.PushScope();
     foreach (IXmlNode xmlNode3 in (IEnumerable<IXmlNode>) xmlNode2.Attributes)
     {
       if (xmlNode3.NamespaceUri == "http://www.w3.org/2000/xmlns/" && xmlNode3.LocalName != "xmlns")
         manager.AddNamespace(xmlNode3.LocalName, xmlNode3.Value);
     }
   }
 }
开发者ID:Zeludon,项目名称:FEZ,代码行数:26,代码来源:XmlNodeConverter.cs

示例3: CreateVSProjectFromFromFolder

		public VSProject CreateVSProjectFromFromFolder(string name, string folder, ProjectType type)
		{
			XmlDocument doc = new XmlDocument(new NameTable());

			XmlNamespaceManager nsManager = new XmlNamespaceManager(doc.NameTable);
			nsManager.AddNamespace("", "http://schemas.microsoft.com/developer/msbuild/2003");
			nsManager.PushScope();

			doc.Load(Path.Combine(context.TemplateFolder.FullName, "VS/CSProject_template.xml"));

			return VSProject.Create(name, folder, type, doc);
		}
开发者ID:nats,项目名称:castle-1.0.3-mono,代码行数:12,代码来源:DefaultGeneratorService.cs

示例4: XQueryContextManager

		internal XQueryContextManager (XQueryStaticContext ctx, XPathItem input, XmlWriter writer, XmlResolver resolver, XmlArgumentList args)
		{
			this.input = input;
			this.staticContext = ctx;
			this.args = args;
			currentWriter = writer;
			this.extDocResolver = resolver;

			namespaceManager = new XmlNamespaceManager (ctx.NameTable);
			foreach (DictionaryEntry de in ctx.NSResolver.GetNamespacesInScope (XmlNamespaceScope.ExcludeXml))
				namespaceManager.AddNamespace (de.Key.ToString (), de.Value.ToString ());
			namespaceManager.PushScope ();

			currentContext = new XQueryContext (this, null, new Hashtable ());
			if (input != null) {
				currentSequence = new SingleItemIterator (input, currentContext);
				currentSequence.MoveNext ();
			}
			currentContext = new XQueryContext (this, currentSequence, new Hashtable ());
		}
开发者ID:Profit0004,项目名称:mono,代码行数:20,代码来源:XQueryContext.cs

示例5: SvgDocument

 public SvgDocument()
 {
     this.styleElements = new ArrayList();
     this.recordanim = true;
     this.playAnim = false;
     this.controltime = 0;
     this.filename = "���";
     this.update = true;
     this.undoStack = new UndoStack();
     this.xmlreader = null;
     this.preelement = null;
     this.elements = new ArrayList(0x10);
     this.infos = new Hashtable(0x10);
     this.groups = new ArrayList(0x10);
     this.undoGroup = new ArrayList(0x10);
     this.errorinfos = new ArrayList(0x10);
     this.selectCollection = new SvgElementCollection();
     this.oldSelect = new SvgElementCollection();
     this.root = null;
     this.serialize = null;
     this.editRoots = new SvgElementCollection();
     //this.styleSheetList = null;
     this.ChangeElements = new SvgElementCollection();
     this.NumberOfUndoOperations = 1;
     this.ValidPath = new GraphicsPath();
     this.firstload = false;
     this.FilePath = string.Empty;
     this.SmoothingMode = System.Drawing.Drawing2D.SmoothingMode.HighQuality;
     this.TextRenderingHint = System.Drawing.Text.TextRenderingHint.SystemDefault;
     this.Changed = false;
     this.SelectChanged = false;
     this.OnlyShowCurrent = false;
     this.DefsChanged = true;
     this.OldControlTime = 0;
     this.PlayAnimChanged = false;
     this.AutoShowAnim = false;
     this.XmlParserContext = null;
     XmlNamespaceManager manager1 = new XmlNamespaceManager(base.NameTable);
     manager1.PushScope();
     manager1.AddNamespace("svg", SvgDocument.SvgNamespace);
     manager1.AddNamespace("xlink", SvgDocument.XLinkNamespace);
     manager1.AddNamespace("a", SvgDocument.AudioNamespace);
     manager1.AddNamespace("tonli", SvgDocument.TonliNamespace);
     base.NodeChanged += new XmlNodeChangedEventHandler(this.ChangeNode);
     base.NodeInserted += new XmlNodeChangedEventHandler(this.ChangeNode);
     base.NodeRemoved += new XmlNodeChangedEventHandler(this.ChangeNode);
     this.XmlParserContext = new System.Xml.XmlParserContext(base.NameTable, manager1, "", "svg", "-//W3C//DTD SVG 1.1//EN", "http://www.w3.org/Graphics/SVG/1.1/DTD/svg11.dtd", this.BaseURI, "zh", XmlSpace.None, Encoding.UTF8);
     this.selectCollection.NotifyEvent = true;
     this.selectCollection.OnCollectionChangedEvent += new OnCollectionChangedEventHandler(this.ChangeSelect);
     this.serialize = new SerializeDocument(this);
     this.AddStyleElement(SvgDocument.SvgNamespace, "style");
     this.SvgdataUid=string.Empty;
     layers =new SvgElementCollection();
 }
开发者ID:EdgarEDT,项目名称:myitoppsp,代码行数:54,代码来源:SvgDocument.cs

示例6: PushParentNamespaces

    private void PushParentNamespaces(IXmlNode node, XmlNamespaceManager manager)
    {
      List<IXmlNode> parentElements = null;

      IXmlNode parent = node;
      while ((parent = parent.ParentNode) != null)
      {
        if (parent.NodeType == XmlNodeType.Element)
        {
          if (parentElements == null)
            parentElements = new List<IXmlNode>();

          parentElements.Add(parent);
        }
      }

      if (parentElements != null)
      {
        parentElements.Reverse();

        foreach (IXmlNode parentElement in parentElements)
        {
          manager.PushScope();
          foreach (IXmlNode attribute in parentElement.Attributes)
          {
            if (attribute.NamespaceUri == "http://www.w3.org/2000/xmlns/" && attribute.LocalName != "xmlns")
              manager.AddNamespace(attribute.LocalName, attribute.Value);
          }
        }
      }
    }
开发者ID:284247028,项目名称:MvvmCross,代码行数:31,代码来源:XmlNodeConverter.cs

示例7: DeserializeValue


//.........这里部分代码省略.........
            {
              // read properties until first non-attribute is encountered
              while (!finishedAttributes && !finishedElement && reader.Read())
              {
                switch (reader.TokenType)
                {
                  case JsonToken.PropertyName:
                    string attributeName = reader.Value.ToString();

                    if (attributeName[0] == '@')
                    {
                      attributeName = attributeName.Substring(1);
                      reader.Read();
                      string attributeValue = reader.Value.ToString();
                      attributeNameValues.Add(attributeName, attributeValue);

                      string namespacePrefix;

                      if (IsNamespaceAttribute(attributeName, out namespacePrefix))
                      {
                        manager.AddNamespace(namespacePrefix, attributeValue);
                      }
                    }
                    else
                    {
                      finishedAttributes = true;
                    }
                    break;
                  case JsonToken.EndObject:
                    finishedElement = true;
                    break;
                  default:
                    throw new JsonSerializationException("Unexpected JsonToken: " + reader.TokenType);
                }
              }
            }

            // have to wait until attributes have been parsed before creating element
            // attributes may contain namespace info used by the element
            XmlElement element = (!string.IsNullOrEmpty(elementPrefix))
                    ? document.CreateElement(propertyName, manager.LookupNamespace(elementPrefix))
                    : document.CreateElement(propertyName);

            currentNode.AppendChild(element);

            // add attributes to newly created element
            foreach (KeyValuePair<string, string> nameValue in attributeNameValues)
            {
              string attributePrefix = GetPrefix(nameValue.Key);

              XmlAttribute attribute = (!string.IsNullOrEmpty(attributePrefix))
                      ? document.CreateAttribute(nameValue.Key, manager.LookupNamespace(attributePrefix))
                      : document.CreateAttribute(nameValue.Key);

              attribute.Value = nameValue.Value;

              element.SetAttributeNode(attribute);
            }

            if (reader.TokenType == JsonToken.String)
            {
              element.AppendChild(document.CreateTextNode(reader.Value.ToString()));
            }
            else if (reader.TokenType == JsonToken.Integer)
            {
              element.AppendChild(document.CreateTextNode(XmlConvert.ToString((long)reader.Value)));
            }
            else if (reader.TokenType == JsonToken.Float)
            {
              element.AppendChild(document.CreateTextNode(XmlConvert.ToString((double)reader.Value)));
            }
            else if (reader.TokenType == JsonToken.Boolean)
            {
              element.AppendChild(document.CreateTextNode(XmlConvert.ToString((bool)reader.Value)));
            }
            else if (reader.TokenType == JsonToken.Date)
            {
              DateTime d = (DateTime)reader.Value;
              element.AppendChild(document.CreateTextNode(XmlConvert.ToString(d, DateTimeUtils.ToSerializationMode(d.Kind))));
            }
            else if (reader.TokenType == JsonToken.Null)
            {
              // empty element. do nothing
            }
            else
            {
              // finished element will have no children to deserialize
              if (!finishedElement)
              {
                manager.PushScope();

                DeserializeNode(reader, document, manager, element);

                manager.PopScope();
              }
            }
          }
          break;
      }
    }
开发者ID:matthewcanty,项目名称:worldpay-lib-dotnet,代码行数:101,代码来源:XmlNodeConverter.cs

示例8: DeserializeValue

        private void DeserializeValue(Newtonsoft.Json.JsonReader reader, XmlDocument document, XmlNamespaceManager manager, string propertyName, XmlNode currentNode)
        {
            // deserialize xml element
            bool finishedAttributes = false;
            bool finishedElement = false;
            Dictionary<string, string> attributeNameValues = new Dictionary<string, string>();

            // a string token means the element only has a single text child
            if (reader.TokenType != JsonToken.String
              && reader.TokenType != JsonToken.Null
              && reader.TokenType != JsonToken.Boolean
              && reader.TokenType != JsonToken.Integer
              && reader.TokenType != JsonToken.Float
              && reader.TokenType != JsonToken.Date
              && reader.TokenType != JsonToken.StartConstructor)
            {
                // read properties until first non-attribute is encountered
                while (!finishedAttributes && !finishedElement && reader.Read())
                {
                    switch (reader.TokenType)
                    {
                        case JsonToken.PropertyName:
                            string attributeName = reader.Value.ToString();

                            if (attributeName[0] == '@')
                            {
                                attributeName = attributeName.Substring(1);
                                reader.Read();
                                string attributeValue = reader.Value.ToString();
                                attributeNameValues.Add(attributeName, attributeValue);
                            }
                            else
                            {
                                finishedAttributes = true;
                            }
                            break;
                        case JsonToken.EndObject:
                            finishedElement = true;
                            break;
                        default:
                            throw new JsonSerializationException("Unexpected JsonToken: " + reader.TokenType);
                    }
                }
            }

            // have to wait until attributes have been parsed before creating element
            // attributes may contain namespace info used by the element
            XmlElement element = document.CreateElement(propertyName);

            currentNode.AppendChild(element);

            // add attributes to newly created element
            foreach (KeyValuePair<string, string> nameValue in attributeNameValues)
            {
                XmlAttribute attribute = document.CreateAttribute(nameValue.Key);

                attribute.Value = nameValue.Value;

                element.SetAttributeNode(attribute);
            }

            if (reader.TokenType == JsonToken.String)
            {
                element.AppendChild(document.CreateTextNode(reader.Value.ToString()));
            }
            else if (reader.TokenType == JsonToken.Integer)
            {
                element.AppendChild(document.CreateTextNode(XmlConvert.ToString((long)reader.Value)));
            }
            else if (reader.TokenType == JsonToken.Float)
            {
                element.AppendChild(document.CreateTextNode(XmlConvert.ToString((double)reader.Value)));
            }
            else if (reader.TokenType == JsonToken.Boolean)
            {
                element.AppendChild(document.CreateTextNode(XmlConvert.ToString((bool)reader.Value)));
            }
            else if (reader.TokenType == JsonToken.Date)
            {
                DateTime d = (DateTime)reader.Value;
                element.AppendChild(document.CreateTextNode(XmlConvert.ToString(d, ToSerializationMode(d.Kind))));
            }
            else if (reader.TokenType == JsonToken.Null)
            {
                // empty element. do nothing
            }
            else
            {
                // finished element will have no children to deserialize
                if (!finishedElement)
                {
                    manager.PushScope();

                    DeserializeNode(reader, document, manager, element);

                    manager.PopScope();
                }
            }
        }
开发者ID:pgodwin,项目名称:Ext.net,代码行数:99,代码来源:RecordsToXmlConverter.cs

示例9: ProcessContent

	public override XmlDocument ProcessContent(XmlDocument docToProcess)
	{

		Message (TraceLevel.Info, "x1");
		XmlNamespaceManager nsmgr = new XmlNamespaceManager(docToProcess.NameTable);
		nsmgr.AddNamespace("default", "http://www.w3.org/1999/xhtml");
		nsmgr.AddNamespace("monodoc", "http://www.go-mono.org/xml/monodoc");
		nsmgr.PushScope();

		Message (TraceLevel.Info, "x2");
		XmlElement root = docToProcess.DocumentElement;
		XmlNode body = root.SelectSingleNode("/default:html/default:body", nsmgr);

		// Use the DC.Description meta tag as sign, that the file is in the new format

		Message (TraceLevel.Info, "x3");
		if (root.SelectNodes("/default:html/default:head/default:meta[@name='DC.Description']", nsmgr).Count != 0)

		{


			//////////////////////////////////////////////////////////////////////
			// Start of temporary code, until the tutorial is converted completely
			//////////////////////////////////////////////////////////////////////

			XmlNodeList nodeList = docToProcess.GetElementsByTagName("div");
		
			/* Remove the mono handbook specific decorations */
		        foreach(XmlNode node in nodeList)
			{
				string cssClass = ((XmlElement)node).GetAttribute("class");
				if (cssClass != null && (cssClass == "topframe" || cssClass == "navbar" || cssClass == "copyright"))
				{
					node.RemoveAll();
				}
	                                                                                
			}
	                                                                                
	
			string headinginner = "Mono Handbook";
			XmlNode firstheading = docToProcess.GetElementsByTagName("title")[0];
			headinginner = firstheading.InnerXml;
	
	
			try {
	
				XmlNode bodynode =  docToProcess.GetElementsByTagName("body")[0];
				bodynode.InnerXml =	"<table width=\"100%\">" +
					"<tr bgcolor=\"#b0c4de\"><td><i></i>Mono Handbook<h3>" + headinginner + "</h3></td></tr></table><p />" +
				bodynode.InnerXml;
			}
			catch {
			}

			Message (TraceLevel.Info, "x5");

			//////////////////////////////////////////////////////////////////////
			// End of temporary code, until the tutorial is converted completely
			//////////////////////////////////////////////////////////////////////
	
			XmlNodeList nodeList2 = docToProcess.GetElementsByTagName("pre");
			foreach(XmlNode node in nodeList2)
			{
				string cssClass = ((XmlElement)node).GetAttribute("class");
	
				if (cssClass != null) {
	
					switch(cssClass)       
					{         
	
					case "code":   
		
						node.InnerXml = "<table width='100%' border='0' cellspacing='0' cellpadding='3'><tr><td>" + 
							"<table width='100%' border='0' cellspacing='0' cellpadding='0' height='100%'>" + 
							"<tr><td bgcolor='#c0c0c0'><img src='/html/en/images/empty.png' width='1' height='1' /></td>" + 
							"<td bgcolor='#c0c0c0'><img src='/html/en/images/empty.png' width='1' height='1' /></td>" + 
							"<td bgcolor='#c0c0c0'><img src='/html/en/images/empty.png' width='1' height='1' /></td>" + 
							"</tr><tr> <td bgcolor='#c0c0c0'> </td><td width='100%' bgcolor='#efefef'> " + 
							"<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td bgcolor='#ffffff'>" + 
							"<table width='100%' border='0' cellspacing='0' cellpadding='2'><tr><td bgcolor='#efefef'><pre>" + 
	
						node.InnerXml +
		
							"</pre></td></tr></table></td></tr></table></td><td bgcolor='#999999'><img src='/html/en/images/empty.png' width='1' height='1' /></td>" + 
							"</tr><tr> <td bgcolor='#c0c0c0'><img src='/html/en/images/empty.png' width='1' height='1' /></td>" + 
							"<td bgcolor='#c0c0c0'><img src='/html/en/images/empty.png' width='1' height='1' /></td>" + 
							"<td bgcolor='#c0c0c0'><img src='/html/en/images/empty.png' width='1' height='1' /></td>" + 
							"</tr></table></td></tr></table>";
	
					break;        
			     	    	case "console":   
		
						node.InnerXml = "<table width='100%' border='0' cellspacing='0' cellpadding='3'><tr><td>" + 
							"<table width='100%' border='0' cellspacing='0' cellpadding='0' height='100%'>" + 
							"<tr><td bgcolor='#555555'><img src='/html/en/images/empty.png' width='1' height='1' /></td>" + 
							"<td bgcolor='#555555'><img src='/html/en/images/empty.png' width='1' height='1' /></td>" + 
							"<td bgcolor='#555555'><img src='/html/en/images/empty.png' width='1' height='1' /></td>" + 
							"</tr><tr> <td bgcolor='#c0c0c0'> </td><td width='100%' bgcolor='#efefef'> " + 
							"<table width='100%' border='0' cellspacing='0' cellpadding='0'><tr><td bgcolor='#ffffff'>" + 
							"<table width='100%' border='0' cellspacing='0' cellpadding='2'><tr><td bgcolor='#999999'><pre>" + 
//.........这里部分代码省略.........
开发者ID:calumjiao,项目名称:Mono-Class-Libraries,代码行数:101,代码来源:monohb-provider.cs

示例10: GetContext

#pragma warning restore 618

        private XmlParserContext GetContext(XmlNode node)
        {
            String lang = null;
            XmlSpace spaceMode = XmlSpace.None;
            XmlDocumentType docType = _doc.DocumentType;
            String baseURI = _doc.BaseURI;
            //constructing xmlnamespace
            HashSet<string> prefixes = new HashSet<string>();
            XmlNameTable nt = _doc.NameTable;
            XmlNamespaceManager mgr = new XmlNamespaceManager(nt);
            bool bHasDefXmlnsAttr = false;

            // Process all xmlns, xmlns:prefix, xml:space and xml:lang attributes
            while (node != null && node != _doc)
            {
                XmlElement element = node as XmlElement;
                if (element != null && element.HasAttributes)
                {
                    mgr.PushScope();
                    foreach (XmlAttribute attr in element.Attributes)
                    {
                        if (attr.Prefix == _doc.strXmlns && !prefixes.Contains(attr.LocalName))
                        {
                            // Make sure the next time we will not add this prefix
                            prefixes.Add(attr.LocalName);
                            mgr.AddNamespace(attr.LocalName, attr.Value);
                        }
                        else if (!bHasDefXmlnsAttr && attr.Prefix.Length == 0 && attr.LocalName == _doc.strXmlns)
                        {
                            // Save the case xmlns="..." where xmlns is the LocalName
                            mgr.AddNamespace(String.Empty, attr.Value);
                            bHasDefXmlnsAttr = true;
                        }
                        else if (spaceMode == XmlSpace.None && attr.Prefix == _doc.strXml && attr.LocalName == _doc.strSpace)
                        {
                            // Save xml:space context
                            if (attr.Value == "default")
                                spaceMode = XmlSpace.Default;
                            else if (attr.Value == "preserve")
                                spaceMode = XmlSpace.Preserve;
                        }
                        else if (lang == null && attr.Prefix == _doc.strXml && attr.LocalName == _doc.strLang)
                        {
                            // Save xml:lag context
                            lang = attr.Value;
                        }
                    }
                }
                node = node.ParentNode;
            }
            return new XmlParserContext(
                nt,
                mgr,
                (docType == null) ? null : docType.Name,
                (docType == null) ? null : docType.PublicId,
                (docType == null) ? null : docType.SystemId,
                (docType == null) ? null : docType.InternalSubset,
                baseURI,
                lang,
                spaceMode
                );
        }
开发者ID:ChuangYang,项目名称:corefx,代码行数:64,代码来源:XmlLoader.cs

示例11: SerializeNode

        private void SerializeNode(JsonWriter writer, IXmlNode node, XmlNamespaceManager manager, bool writePropertyName)
        {
            switch (node.NodeType)
            {
                case XmlNodeType.Document:
                case XmlNodeType.DocumentFragment:
                    SerializeGroupedNodes(writer, node, manager, writePropertyName);
                    break;
                case XmlNodeType.Element:
                    if (IsArray(node) && node.ChildNodes.All(n => n.LocalName == node.LocalName) && node.ChildNodes.Count > 0)
                    {
                        SerializeGroupedNodes(writer, node, manager, false);
                    }
                    else
                    {
                        manager.PushScope();

                        foreach (IXmlNode attribute in node.Attributes)
                        {
                            if (attribute.NamespaceUri == "http://www.w3.org/2000/xmlns/")
                            {
                                string namespacePrefix = (attribute.LocalName != "xmlns")
                                    ? attribute.LocalName
                                    : string.Empty;
                                string namespaceUri = attribute.Value;

                                manager.AddNamespace(namespacePrefix, namespaceUri);
                            }
                        }

                        if (writePropertyName)
                            writer.WritePropertyName(GetPropertyName(node, manager));

                        if (!ValueAttributes(node.Attributes).Any() && node.ChildNodes.Count == 1
                            && node.ChildNodes[0].NodeType == XmlNodeType.Text)
                        {
                            // write elements with a single text child as a name value pair
                            writer.WriteValue(node.ChildNodes[0].Value);
                        }
                        else if (node.ChildNodes.Count == 0 && CollectionUtils.IsNullOrEmpty(node.Attributes))
                        {
                            IXmlElement element = (IXmlElement)node;

                            // empty element
                            if (element.IsEmpty)
                                writer.WriteNull();
                            else
                                writer.WriteValue(string.Empty);
                        }
                        else
                        {
                            writer.WriteStartObject();

                            for (int i = 0; i < node.Attributes.Count; i++)
                            {
                                SerializeNode(writer, node.Attributes[i], manager, true);
                            }

                            SerializeGroupedNodes(writer, node, manager, true);

                            writer.WriteEndObject();
                        }

                        manager.PopScope();
                    }

                    break;
                case XmlNodeType.Comment:
                    if (writePropertyName)
                        writer.WriteComment(node.Value);
                    break;
                case XmlNodeType.Attribute:
                case XmlNodeType.Text:
                case XmlNodeType.CDATA:
                case XmlNodeType.ProcessingInstruction:
                case XmlNodeType.Whitespace:
                case XmlNodeType.SignificantWhitespace:
                    if (node.NamespaceUri == "http://www.w3.org/2000/xmlns/" && node.Value == JsonNamespaceUri)
                        return;

                    if (node.NamespaceUri == JsonNamespaceUri)
                    {
                        if (node.LocalName == "Array")
                            return;
                    }

                    if (writePropertyName)
                        writer.WritePropertyName(GetPropertyName(node, manager));
                    writer.WriteValue(node.Value);
                    break;
                case XmlNodeType.XmlDeclaration:
                    IXmlDeclaration declaration = (IXmlDeclaration)node;
                    writer.WritePropertyName(GetPropertyName(node, manager));
                    writer.WriteStartObject();

                    if (!string.IsNullOrEmpty(declaration.Version))
                    {
                        writer.WritePropertyName("@version");
                        writer.WriteValue(declaration.Version);
                    }
//.........这里部分代码省略.........
开发者ID:Henry-T,项目名称:UnityPG,代码行数:101,代码来源:XmlNodeConverter.cs

示例12: GetThumbBitmapFromYT

        /// <summary>
        /// Get YouTube thumbnail of the video with specified ID 
        /// </summary>
        /// <param name="id">Id of the video to get thumbnail of</param>
        /// <returns>BitmapSource of the preview</returns>
        internal static BitmapSource GetThumbBitmapFromYT(string id)
        {
            XmlDocument doc = new XmlDocument();

            XmlNamespaceManager ns = new XmlNamespaceManager(doc.NameTable);
            doc.Load("http://gdata.youtube.com/feeds/api/videos/" + id);

            ns.AddNamespace("", "http://www.w3.org/2005/Atom");
            ns.AddNamespace("media", "http://search.yahoo.com/mrss/");
            ns.PushScope();

            XmlElement root = doc.DocumentElement;
            XmlNodeList list = root.ChildNodes;

            string videoThumbUrl;
            foreach (XmlNode node in list)
            {
                if (node.Name == "media:group")
                {
                    XmlNode thumbnail = node.SelectSingleNode("media:thumbnail", ns);
                    videoThumbUrl = thumbnail.Attributes["url"].Value;

                    return Utils.GetImage(new Uri(videoThumbUrl));
                }
            }

            return null;
        }
开发者ID:fashaikh,项目名称:ChronoZoom,代码行数:33,代码来源:Thumbs.cs

示例13: SerializeNode

 // Token: 0x060006E1 RID: 1761
 // RVA: 0x00037C10 File Offset: 0x00035E10
 private void SerializeNode(JsonWriter writer, IXmlNode node, XmlNamespaceManager manager, bool writePropertyName)
 {
     switch (node.NodeType)
     {
     case XmlNodeType.Element:
         if (this.IsArray(node))
         {
             if (Enumerable.All<IXmlNode>(node.ChildNodes, (IXmlNode n) => n.LocalName == node.LocalName) && node.ChildNodes.Count > 0)
             {
                 this.SerializeGroupedNodes(writer, node, manager, false);
                 return;
             }
         }
         manager.PushScope();
         foreach (IXmlNode current in node.Attributes)
         {
             if (current.NamespaceUri == "http://www.w3.org/2000/xmlns/")
             {
                 string prefix = (current.LocalName != "xmlns") ? current.LocalName : string.Empty;
                 string value = current.Value;
                 manager.AddNamespace(prefix, value);
             }
         }
         if (writePropertyName)
         {
             writer.WritePropertyName(this.GetPropertyName(node, manager));
         }
         if (!Enumerable.Any<IXmlNode>(this.ValueAttributes(node.Attributes)) && node.ChildNodes.Count == 1 && node.ChildNodes[0].NodeType == XmlNodeType.Text)
         {
             writer.WriteValue(node.ChildNodes[0].Value);
         }
         else if (node.ChildNodes.Count == 0 && CollectionUtils.IsNullOrEmpty<IXmlNode>(node.Attributes))
         {
             IXmlElement xmlElement = (IXmlElement)node;
             if (xmlElement.IsEmpty)
             {
                 writer.WriteNull();
             }
             else
             {
                 writer.WriteValue(string.Empty);
             }
         }
         else
         {
             writer.WriteStartObject();
             for (int i = 0; i < node.Attributes.Count; i++)
             {
                 this.SerializeNode(writer, node.Attributes[i], manager, true);
             }
             this.SerializeGroupedNodes(writer, node, manager, true);
             writer.WriteEndObject();
         }
         manager.PopScope();
         return;
     case XmlNodeType.Attribute:
     case XmlNodeType.Text:
     case XmlNodeType.CDATA:
     case XmlNodeType.ProcessingInstruction:
     case XmlNodeType.Whitespace:
     case XmlNodeType.SignificantWhitespace:
         if (node.NamespaceUri == "http://www.w3.org/2000/xmlns/" && node.Value == "http://james.newtonking.com/projects/json")
         {
             return;
         }
         if (node.NamespaceUri == "http://james.newtonking.com/projects/json" && node.LocalName == "Array")
         {
             return;
         }
         if (writePropertyName)
         {
             writer.WritePropertyName(this.GetPropertyName(node, manager));
         }
         writer.WriteValue(node.Value);
         return;
     case XmlNodeType.Comment:
         if (writePropertyName)
         {
             writer.WriteComment(node.Value);
             return;
         }
         return;
     case XmlNodeType.Document:
     case XmlNodeType.DocumentFragment:
         this.SerializeGroupedNodes(writer, node, manager, writePropertyName);
         return;
     case XmlNodeType.DocumentType:
     {
         IXmlDocumentType xmlDocumentType = (IXmlDocumentType)node;
         writer.WritePropertyName(this.GetPropertyName(node, manager));
         writer.WriteStartObject();
         if (!string.IsNullOrEmpty(xmlDocumentType.Name))
         {
             writer.WritePropertyName("@name");
             writer.WriteValue(xmlDocumentType.Name);
         }
         if (!string.IsNullOrEmpty(xmlDocumentType.Public))
         {
//.........这里部分代码省略.........
开发者ID:newchild,项目名称:Project-DayZero,代码行数:101,代码来源:XmlNodeConverter.cs

示例14: ReadElement

 // Token: 0x060006E4 RID: 1764
 // RVA: 0x000382C8 File Offset: 0x000364C8
 private void ReadElement(JsonReader reader, IXmlDocument document, IXmlNode currentNode, string propertyName, XmlNamespaceManager manager)
 {
     if (string.IsNullOrEmpty(propertyName))
     {
         throw new JsonSerializationException("XmlNodeConverter cannot convert JSON with an empty property name to XML.");
     }
     Dictionary<string, string> dictionary = this.ReadAttributeElements(reader, manager);
     string prefix = MiscellaneousUtils.GetPrefix(propertyName);
     if (StringUtils.StartsWith(propertyName, '@'))
     {
         string text = propertyName.Substring(1);
         string value = reader.Value.ToString();
         string prefix2 = MiscellaneousUtils.GetPrefix(text);
         IXmlNode attributeNode = (!string.IsNullOrEmpty(prefix2)) ? document.CreateAttribute(text, manager.LookupNamespace(prefix2), value) : document.CreateAttribute(text, value);
         ((IXmlElement)currentNode).SetAttributeNode(attributeNode);
         return;
     }
     IXmlElement xmlElement = this.CreateElement(propertyName, document, prefix, manager);
     currentNode.AppendChild(xmlElement);
     foreach (KeyValuePair<string, string> current in dictionary)
     {
         string prefix3 = MiscellaneousUtils.GetPrefix(current.Key);
         IXmlNode attributeNode2 = (!string.IsNullOrEmpty(prefix3)) ? document.CreateAttribute(current.Key, manager.LookupNamespace(prefix3), current.Value) : document.CreateAttribute(current.Key, current.Value);
         xmlElement.SetAttributeNode(attributeNode2);
     }
     if (reader.TokenType != JsonToken.String && reader.TokenType != JsonToken.Integer && reader.TokenType != JsonToken.Float && reader.TokenType != JsonToken.Boolean)
     {
         if (reader.TokenType != JsonToken.Date)
         {
             if (reader.TokenType == JsonToken.Null)
             {
                 return;
             }
             if (reader.TokenType != JsonToken.EndObject)
             {
                 manager.PushScope();
                 this.DeserializeNode(reader, document, manager, xmlElement);
                 manager.PopScope();
             }
             manager.RemoveNamespace(string.Empty, manager.DefaultNamespace);
             return;
         }
     }
     xmlElement.AppendChild(document.CreateTextNode(this.ConvertTokenToXmlValue(reader)));
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:47,代码来源:XmlNodeConverter.cs

示例15: PushParentNamespaces

 // Token: 0x060006DC RID: 1756
 // RVA: 0x00037820 File Offset: 0x00035A20
 private void PushParentNamespaces(IXmlNode node, XmlNamespaceManager manager)
 {
     List<IXmlNode> list = null;
     IXmlNode xmlNode = node;
     while ((xmlNode = xmlNode.ParentNode) != null)
     {
         if (xmlNode.NodeType == XmlNodeType.Element)
         {
             if (list == null)
             {
                 list = new List<IXmlNode>();
             }
             list.Add(xmlNode);
         }
     }
     if (list != null)
     {
         list.Reverse();
         foreach (IXmlNode current in list)
         {
             manager.PushScope();
             foreach (IXmlNode current2 in current.Attributes)
             {
                 if (current2.NamespaceUri == "http://www.w3.org/2000/xmlns/" && current2.LocalName != "xmlns")
                 {
                     manager.AddNamespace(current2.LocalName, current2.Value);
                 }
             }
         }
     }
 }
开发者ID:newchild,项目名称:Project-DayZero,代码行数:33,代码来源:XmlNodeConverter.cs


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