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


C# XmlNode.GetAttributeValue方法代码示例

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


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

示例1: CreateWeapon

        private Weapon CreateWeapon(XmlNode weaponNode)
        {
            var weapon = new Weapon();

            weapon.Id = weaponNode.GetAttributeValue("id").ToInt();
            weapon.Name = weaponNode.GetAttributeValue("name");
            weapon.Power = weaponNode.GetAttributeValue("power").ToInt();
            weapon.MagicPower = weaponNode.GetAttributeValue("magicPower").ToInt();
            weapon.Value = weaponNode.GetAttributeValue("value").ToInt();

            return weapon;
        }
开发者ID:mildsauce45,项目名称:NowItsOurTurn,代码行数:12,代码来源:WeaponManager.cs

示例2: Style

        /// <summary>
        ///   Initializes a new instance of the <see cref="Style" /> class.
        /// </summary>
        /// <param name="styleNode"> The style node. </param>
        /// <param name="storage"> The storage. </param>
        public Style(XmlNode styleNode, IPhysicalStorage storage)
        {
            _storage = storage;
              _id = styleNode.GetId();
              _isDefault = styleNode.GetAttributeBoolValue("isdefault");
              _name = styleNode.GetAttributeValue("name");

              _foregroundColor = styleNode.GetNodeColorValue("Foreground", "color");
              _font = styleNode.GetNodeValue("Foreground", "font");
              _fontSize = styleNode.GetNodeIntValue("Foreground", "fontsize");

              if (styleNode.HasNode("Background"))
              {
            _backgroundColor = styleNode.GetNodeColorValue("Background", "color");

            if (styleNode.HasNode("Background", "image"))
            {
              _backgroundImageUri = styleNode.GetNodeValue("Background", "image", "uri");

              var cache = styleNode.GetNodeValue("Background", "image", "cache");
              if (!string.IsNullOrEmpty(cache))
              {
            _backgroundImage = ImageSerializer.DeserializeBase64(cache);
              }
              else if (File.Exists(_backgroundImageUri))
              {
            _backgroundImage = Image.FromFile(_backgroundImageUri);
              }

              _transparency = styleNode.GetNodeIntValue("Background", "image", "transparency");
              _scale = styleNode.GetNodeBoolValue("Background", "image", "scale");
            }

            if (styleNode.HasNode("Title"))
            {
              _titleMode = TitleModeExtensions.AsTitleMode(styleNode["Title"].GetAttributeValue("mode"));

              if (styleNode.HasNode("Title", "Foreground"))
              {
            _titleForegroundColor = styleNode.GetNodeColorValue("Title", "Foreground", "color");
            _titleFont = styleNode.GetNodeValue("Title", "Foreground", "font");
            _titleFontSize = styleNode.GetNodeIntValue("Title", "Foreground", "fontsize");
              }
              if (styleNode.HasNode("Title", "Background"))
              {
            _titleBackgroundColor = styleNode.GetNodeColorValue("Title", "Background", "color");
              }
            }
              }
        }
开发者ID:ogirard,项目名称:lyra2,代码行数:55,代码来源:Style.cs

示例3: BaseLexer

        public BaseLexer(int firstFreeStyle, XmlNode lexerNode, BaseLexer parent)
        {
            parentLexer = parent;
            defaultLexer = GetType().Name == "DefaultLexer" ? null
                : new DefaultLexer(firstFreeStyle, null, this);

            // get style and state ranges
            var stateValues = Enum.GetValues(StateType);
            int styleCount = stateValues.Length;
            int firstState = styleCount > 0 ? ((int[])stateValues).Min() : 0;

            // adjust style ranges if they fall into the Scintilla styles
            firstStyle = firstFreeStyle;
            if (SciStyle.Default <= firstStyle + styleCount && firstStyle <= SciStyle.CallTip)
                firstStyle = SciStyle.CallTip + 1;
            lastStyle = firstStyle + styleCount - 1;
            firstFreeStyle = lastStyle + 1;

            if (StateType.IsEquivalentTo(typeof(BaseState)))
            {
                firstBaseStyle = firstStyle;
                lastBaseStyle = lastStyle;
            }

            // allocate arrays for styles
            styles = Enumerable.Range(firstStyle, styleCount)
                .Select(x => new ScintillaNET.Lexing.Style {
                    id = x, fore = Theme.ForeColor, back = Theme.Workspace
                }).ToArray();
            keywords = new Trie<Keyword>[styleCount];

            // SET TO DEFAULT LEXER
            if (lexerNode == null)
            {
                lexerType = "default";
                lexer = new BaseLexer[0];
                return;
            }

            // get lexer type
            lexerType = lexerNode.GetAttributeValue("type");

            // get style colors
            var styleList = lexerNode.SelectNodes("Style");
            foreach (XmlNode style in styleList)
            {
                if (style.HasAttributeValue("theme") && style.GetAttributeValue("theme").ToLower() != Theme.Name.ToLower())
                    continue;
                var id = (int)Enum.Parse(StateType, style.GetAttributeValue("name"), true);
                var idx = id - firstState;
                if (style.HasAttributeValue("fore"))
                    styles[idx].fore = ColorTranslator.FromHtml(style.GetAttributeValue("fore"));
                if (style.HasAttributeValue("back"))
                    styles[idx].back = ColorTranslator.FromHtml(style.GetAttributeValue("back"));
            }

            // get keyword definitions
            var keywordList = lexerNode.SelectNodes("Keyword");
            foreach (XmlNode keyword in keywordList)
            {
                var id = (int)Enum.Parse(StateType, keyword.GetAttributeValue("style_name"), true);
                var idx = id - firstState;
                var name = keyword.GetAttributeValue("name");
                var hint = keyword.GetAttributeValue("hint");
                if (hint != null && hint.IndexOf('\\') >= 0)
                    hint = regexHint.Replace(hint, "\n");
                if (keywords[idx] == null)
                    keywords[idx] = new Trie<Keyword>();
                keywords[idx].Add(name, new Keyword { word = name, hint = hint });
            }

            // instantiate sub-lexers
            var lexerList = lexerNode.SelectNodes("Lexer");
            lexer = new BaseLexer[lexerList.Count];
            var assembly = typeof(BaseLexer).FullName.Substring(0,
                typeof(BaseLexer).FullName.Length - typeof(BaseLexer).Name.Length);
            for (int i = 0; i < lexerList.Count; i++)
            {
                var type = lexerList[i].GetAttributeValue("lexer");
                var param = new object[] { firstFreeStyle, lexerList[i], this };
                var t = Type.GetType($"{assembly}{type}");
                lexer[i] = (BaseLexer)Activator.CreateInstance(t, param);
                firstFreeStyle = lexer[i].MaxStyle + 1;
            }
        }
开发者ID:h3tch,项目名称:ProtoFX,代码行数:85,代码来源:FXLexer.cs

示例4: ParseAmazonInfo

		// Amazonへのリンクを追加
		private XmlNode ParseAmazonInfo(XmlNode myNode, int headingLevel){
			string code = myNode.GetAttributeValue(CodeAttribute);
			if(!string.IsNullOrEmpty(code)) myASINList.AddNew(code);
			return Html.CreateDocumentFragment();
		}
开发者ID:bakera,项目名称:Hatomaru.dll,代码行数:6,代码来源:action_nodeparse.cs

示例5: ParseAmazonImage

		// Amazon の画像を生成する
		public XmlNode ParseAmazonImage(XmlNode myNode, int headingLevel){
			string code = myNode.GetAttributeValue(CodeAttribute);
			if(string.IsNullOrEmpty(code)) return Html.Null;
			return GetAmazonImage(code);
		}
开发者ID:bakera,项目名称:Hatomaru.dll,代码行数:6,代码来源:action_nodeparse.cs

示例6: ParseAmazon

// Amazon関連

		// Amazon へのリンクを生成する
		public XmlNode ParseAmazon(XmlNode myNode, int headingLevel){
			XmlElement result = Html.Span("amazon");
			string code = myNode.GetAttributeValue(CodeAttribute);
			if(string.IsNullOrEmpty(code)){
				result.AppendChild(GetLink(myNode, AmazonManager.AmazonTopUrl));
				return result;
			}
			string amazonHref = String.Format(AmazonManager.AmazonHrefFormat, code);
			string amazonSrc = String.Format(AmazonManager.AmazonSrcFormat, code);

			// URL を作成
			XmlNode amazonA = GetLink(myNode, amazonHref);

			XmlElement amazonImg = Html.Img(amazonSrc, "", 1, 1);

			result.AppendChild(amazonA);
			result.AppendChild(amazonImg);

			myASINList.AddNew(code);
			return result;
		}
开发者ID:bakera,项目名称:Hatomaru.dll,代码行数:24,代码来源:action_nodeparse.cs

示例7: ParseFootNote

		// footnote要素を処理します。
		public XmlNode ParseFootNote(XmlNode myNode, int headingLevel){

			// 脚注のぶら下がり先を作る
			if(myFootNote == null){
				myFootNote = Html.Create("dl", "footnotes");
			}
			string fnTitle = myNode.GetAttributeValue(TitleAttribute);
			myFootNoteCount++;
			string fnHeadingId = FootNoteHeadingIdPrefix + myFootNoteCount.ToString();
			string fnLinkId = FootNoteLinkIdPrefix + myFootNoteCount.ToString();
			string fnLinkText = string.Format(FootNoteLinkTextFormat, myFootNoteCount);

			XmlElement fnHeadingAnchor = Html.Create("a");
			fnHeadingAnchor.SetAttribute("name", fnHeadingId);
			fnHeadingAnchor.SetAttribute("id", fnHeadingId);
			fnHeadingAnchor.SetAttribute("href", "#" + fnLinkId);
			fnHeadingAnchor.InnerText = fnLinkText;

			XmlElement fnDt = Html.Create("dt", null, fnHeadingAnchor);
			if(!string.IsNullOrEmpty(fnTitle)) fnDt.AppendChild(Html.Text(" " + fnTitle));
			XmlElement fnDd = Html.Create("dd");
			fnDd.AppendChild(ParseNode(myNode.ChildNodes, headingLevel));
			myFootNote.AppendChild(fnDt);
			myFootNote.AppendChild(fnDd);

			XmlElement fnLinkAnchor = Html.Create("a", FootNoteLinkIdPrefix);
			fnLinkAnchor.SetAttribute("name", fnLinkId);
			fnLinkAnchor.SetAttribute("id", fnLinkId);
			fnLinkAnchor.SetAttribute("href", "#" + fnHeadingId);
			fnLinkAnchor.InnerText = fnLinkText;
			if(!string.IsNullOrEmpty(fnTitle)) fnLinkAnchor.SetAttribute("title", fnTitle);

			return fnLinkAnchor;
		}
开发者ID:bakera,项目名称:Hatomaru.dll,代码行数:35,代码来源:action_nodeparse.cs

示例8: ParseAttr

		// attr要素を処理します。
		public XmlNode ParseAttr(XmlNode myNode, int headingLevel){
			XmlElement result = Html.Create("dfn", "element");
			if(HtmlRef != null){
				string name = myNode.GetAttributeValue(TargetAttribute);
				if(string.IsNullOrEmpty(name)) name = myNode.InnerText;
				name = name.GetIdString();
				string forStr = myNode.GetAttributeValue(ForAttribute);
				HtmlAttribute ha = HtmlRef.GetAttribute(name, forStr);
				if(ha != null){
					AbsPath link = HtmlRef.BasePath.Combine(ha.LinkId, ha.Id.PathEncode());
					XmlElement a = Html.A(link);
					a.AppendChild(ParseNode(myNode.ChildNodes, headingLevel));
					result.AppendChild(a);
					return result;
				}
			}
			result.AppendChild(ParseNode(myNode.ChildNodes, headingLevel));
			return result;
		}
开发者ID:bakera,项目名称:Hatomaru.dll,代码行数:20,代码来源:action_nodeparse.cs

示例9: ParseData

		// data要素を処理します。
		public XmlNode ParseData(XmlNode myNode, int headingLevel){
			XmlElement result = Html.Create("dfn", "data");
			if(HtmlRef != null){
				string name = myNode.GetAttributeValue(TargetAttribute);
				if(string.IsNullOrEmpty(name)) name = myNode.InnerText;
				name = name.GetIdString();
				HtmlData hd = HtmlRef.GetDataByName(name);
				if(hd != null){
					AbsPath link = HtmlRef.BasePath.Combine(hd.LinkId, hd.Id.PathEncode());
					XmlElement a = Html.A(link);
					a.AppendChild(ParseNode(myNode.ChildNodes, headingLevel));
					result.AppendChild(a);
					return result;
				}
			}
			result.AppendChild(ParseNode(myNode.ChildNodes, headingLevel));
			return result;
		}
开发者ID:bakera,项目名称:Hatomaru.dll,代码行数:19,代码来源:action_nodeparse.cs

示例10: ParseDfn

		// dfn要素を処理します。
		public XmlNode ParseDfn(XmlNode myNode, int headingLevel){
			XmlElement result = Html.Create("dfn", "glossary");
			if(Glossary != null){
				string name = myNode.GetAttributeValue(TargetAttribute);
				if(string.IsNullOrEmpty(name)) name = myNode.InnerText;
				GlossaryWord gw = Glossary.GetWordByName(name);
				if(gw != null){
					AbsPath wordLink = Glossary.BasePath.Combine(gw.Name.PathEncode());
					XmlElement a = Html.A(wordLink);
					a.AppendChild(ParseNode(myNode.ChildNodes, headingLevel));
					result.AppendChild(a);
					return result;
				}
			}
			result.AppendChild(ParseNode(myNode.ChildNodes, headingLevel));
			return result;
		}
开发者ID:bakera,项目名称:Hatomaru.dll,代码行数:18,代码来源:action_nodeparse.cs

示例11: ParseDownload

		// download要素を処理します。
		public XmlNode ParseDownload(XmlNode myNode, int headingLevel){
			string href = myNode.GetAttributeValue("href");
			if(string.IsNullOrEmpty(href)){
				href = myNode.InnerText;
			}
			AbsPath path = new AbsPath(href);
			if(path.Equals(myPath)) throw new Exception("ダウンロードリンクに自身が指定されています。");
			FileResponse dlResponse = myModel.Manager.GetResponse(path) as FileResponse;
			if(dlResponse == null){
				return Html.Text("(" + href + "のダウンロードは利用できません)");
			}
			XmlElement a = Html.A(path);
			string inner = string.Format("{0} ({1} {2})", dlResponse.FileSource.Name, dlResponse.ExtInfo.Description, dlResponse.LengthFormat);
			a.InnerText = inner;
			return a;
		}
开发者ID:bakera,项目名称:Hatomaru.dll,代码行数:17,代码来源:action_nodeparse.cs

示例12: ParseA

		// a要素を処理します。
		public XmlNode ParseA(XmlNode myNode, int headingLevel){
			string href = myNode.GetAttributeValue("href");
			if(string.IsNullOrEmpty(href)){
				href = myNode.InnerText;
			}
			return GetLink(myNode, href);
		}
开发者ID:bakera,项目名称:Hatomaru.dll,代码行数:8,代码来源:action_nodeparse.cs

示例13: ParseNode

		// ノードをパースします。
		public XmlNode ParseNode(XmlNode myNode, int headingLevel){
			XmlNode result = null;
			switch(myNode.NodeType){
			case XmlNodeType.Document:
				result = ParseNode(myNode.ChildNodes, headingLevel);
				break;

			case XmlNodeType.Element:
				// 要素の場合
				result = ParseElement(myNode as XmlElement, headingLevel);
				// langかxml:langがあったら継承する
				string lang = myNode.GetAttributeValue("xml:lang");
				if(lang == null) lang = myNode.GetAttributeValue("lang");
				if(result is XmlElement && !string.IsNullOrEmpty(lang)){
					XmlElement e = result as XmlElement;
					e.SetAttribute("xml:lang", lang);
				}
				break;

			case XmlNodeType.Text:
			case XmlNodeType.CDATA:
				// テキストの場合
				string text = myNode.Value;
				text = text.Replace("\t", "    ");
				result = Html.CreateTextNode(text);
				break;

			case XmlNodeType.Comment:
			case XmlNodeType.XmlDeclaration:
			case XmlNodeType.DocumentType:
				// コメントやXML宣言は無視
				result = Html.Null;
				break;

			default:
				//その他のノード
				throw new Exception(String.Format("ノードタイプ {0} は処理できません", myNode.NodeType));
			}

			if(myRoopCounter++ > RoopMax){
				throw new Exception("パースループエラー: パーサーの処理回数が一定量を超えました。無限ループの可能性があるため処理を中止しました。");
			}

			return result;
		}
开发者ID:bakera,项目名称:Hatomaru.dll,代码行数:46,代码来源:action_nodeparse.cs

示例14: GetAttributeValue

        /**
         * Calculates the macro-expanded value of an attribute on the node.
         * Returns true if the attribute is defined.
         */
        bool GetAttributeValue(XmlNode node, XmlMacroCollection macros, string attribName, out string value)
        {
            value = node.GetAttributeValue(attribName);

            if (value != null)
            {
                try
                {
                    value = macros.GetExpandedValue(value);
                }
                catch (Exception ex)
                {
                    throw new JRunXmlException(node, ex, "Could not expand macro value for attribute \"{0}\"", attribName);
                }
            }

            return value != null;
        }
开发者ID:cj3j,项目名称:HotCuts,代码行数:22,代码来源:XmlShortcutFile.cs

示例15: CreateVirtualShortcut

        /**
         * Creates a virtual shortcut for the given context and node
         */
        XmlVirtualShortcut CreateVirtualShortcut(XmlNode context, XmlNode shortcutNode, XmlMacroCollection outerMacros)
        {
            var nodeName = shortcutNode.GetAttributeValue("name");

            if (!String.IsNullOrEmpty(nodeName))
            {
                var realName = outerMacros.GetExpandedValue(nodeName);

                if (!String.IsNullOrEmpty(realName))
                {
                    var newMacros = new XmlMacroCollection(outerMacros);

                    AddTemplateMacros(shortcutNode, newMacros);

                    return new XmlVirtualShortcut(realName, context, shortcutNode, newMacros);
                }
            }

            return null;
        }
开发者ID:cj3j,项目名称:HotCuts,代码行数:23,代码来源:XmlShortcutFile.cs


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