當前位置: 首頁>>代碼示例>>C#>>正文


C# XElement.XPathSelectElements方法代碼示例

本文整理匯總了C#中System.Xml.Linq.XElement.XPathSelectElements方法的典型用法代碼示例。如果您正苦於以下問題:C# XElement.XPathSelectElements方法的具體用法?C# XElement.XPathSelectElements怎麽用?C# XElement.XPathSelectElements使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.Linq.XElement的用法示例。


在下文中一共展示了XElement.XPathSelectElements方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: ApplyDir

        private static void ApplyDir(XElement dirElement, String path)
        {
            path = Path.Combine(path, dirElement.Attribute("name").Value);
            if (!Directory.Exists(path))
                Directory.CreateDirectory(path);

            foreach (var file in dirElement.XPathSelectElements("file"))
                File.Create(Path.Combine(path, file.Attribute("name").Value)).Close();

            foreach (var dir in dirElement.XPathSelectElements("directory"))
                ApplyDir(dir, path);
        }
開發者ID:jluchiji,項目名稱:RenEx,代碼行數:12,代碼來源:Program.Apply.cs

示例2: LoadFromXml

        public void LoadFromXml(XElement xml){
            AddRules(ControllerRule.FromXml(xml .XPathSelectElements("on")));
            xml.XPathSelectElements("map[@role]")
                .Select(n => new{From = n.attr("role").ToUpper(), To = n.attr("as").ToUpper()})
                .map(i => RoleMap.Add(i.From, i.To));
            xml.XPathSelectElements("map[@user]")
                .Select(n => new{From = n.attr("user").ToUpper(), To = n.attr("as").ToUpper()})
                .map(i => UserMap.Add(i.From, i.To));

            var def = xml.First("default");
            if (def.yes()){
                DefaultResult = def.Value;
            }
        }
開發者ID:Qorpent,項目名稱:comdiv.oldcore,代碼行數:14,代碼來源:ControllerRuleGroup.cs

示例3: AddToPackage

        public void AddToPackage(string xPath, XElement document, string package, string formName)
        {
            var nodes = document.XPathSelectElements(xPath);

            foreach (var node in nodes)
            {
                if (node.HasAttributes || node.Attribute("Name") == null ||node.Attribute("Name").Value != package)
                {
                    continue;
                }

                foreach (var child in node.Elements())
                {
                    if (child.Name != "OutputForms")
                    {
                        continue;
                    }

                    var newNode = new XElement("Form");
                    newNode.SetAttributeValue("Name", formName);
                    //node.Parent.AddAfterSelf(newNode);

                    child.Add(newNode);
                }
            }
        }
開發者ID:reekroo,項目名稱:Configurator,代碼行數:26,代碼來源:Add.cs

示例4: Load

        public virtual void Load(PengWorld world, XElement xWorld)
        {
            Contract.Requires(world != null);
            Contract.Requires(xWorld != null);

            foreach (XElement xObj in xWorld.XPathSelectElements(TA.XPathObjects))
            {
                List<ObjectArgumentInfo> args = new List<ObjectArgumentInfo>();
                args.Add(new ObjectArgumentInfo(typeof(string), xObj.Attribute(TA.ObjectID).Value));
                Type objectType;
                if (xObj.Attribute(TA.ObjectType) != null)
                {
                    objectType = Type.GetType(xObj.Attribute(TA.ObjectType).Value);
                    foreach (XElement xArg in xWorld.XPathSelectElements(TA.XPathObjectArgs))
                    {
                        if (xArg.Attribute(TA.ArgumentType) != null)
                            args.Add(GetObjectArgFromXml(xArg));
                    }
                }
                else
                    objectType = typeof(PengObject);

                var ctor = objectType.GetConstructor(args.ConvertAll(x => x.Type).ToArray());
                PengObject obj = (PengObject)ctor.Invoke(args.ConvertAll(x => x.Value).ToArray());
                obj.LoadFromXml(xObj);
            }
        }
開發者ID:fiftin,項目名稱:Pengball,代碼行數:27,代碼來源:Copy+of+PengXmlWorldLoader.cs

示例5: internalListAllUserRoleMaps

		protected override IEnumerable<UserRoleMap> internalListAllUserRoleMaps(XElement lastx) {
			var elements = lastx.XPathSelectElements("//map[@user and @as]");
			foreach (var element in elements) {
				var rm = new UserRoleMap {User = element.attr("user"), Role = element.attr("as")};
				yield return rm;
			}
		}
開發者ID:Qorpent,項目名稱:comdiv.oldcore,代碼行數:7,代碼來源:ClassicXmlRoleApplyer.cs

示例6: Transform

        public XElement Transform(XElement element)
        {
            // <p class="combat">
            var combats = element.XPathSelectElements("p[@class='combat']").ToArray();
            if (combats.Count() == 1)
            {
                var combat = combats.ElementAt(0);

                // <button type="button" class="combat" onclick="Section.fight();">
                combat.Name = "button";
                combat.RemoveAttributes();
                combat.Add(new XAttribute("type", "button"));
                combat.Add(new XAttribute("class", "combat"));
                combat.Add(new XAttribute("onclick", "Section.fight();"));
            }
            else
            {
                for (var index = 0; index < combats.Count(); index++)
                {
                    var combat = combats.ElementAt(index);

                    // <button type="button" class="combat" onclick="Section.fight(X);">
                    combat.Name = "button";
                    combat.RemoveAttributes();
                    combat.Add(new XAttribute("type", "button"));
                    combat.Add(new XAttribute("class", "combat"));
                    combat.Add(new XAttribute("onclick", string.Format("Section.fight({0});", index)));
                }
            }

            return element;
        }
開發者ID:hlaueriksson,項目名稱:LoneWolfMigration,代碼行數:32,代碼來源:Combat.cs

示例7: NavigationLinkBuilder

        public NavigationLinkBuilder(string dimensionsPath)
        {
            dimensions = XElement.Load(dimensionsPath);
            //Create context items for dimension name/value pairs
            foreach(var node in dimensions.XPathSelectElements("//DIMENSION")) {
                string name = node.Attribute("NAME").Value;
                string id = node.Descendants("DIMENSION_ID").First().Attribute("ID").Value;

                var item = new ContextItem() { Name = name, ID = id };
                var count = 0;
                foreach (var descendant in node.Descendants("DIMENSION_NODE"))
                {
                    // Skip first
                    if (count != 0)
                    {
                        // get id
                        var a = descendant.Descendants("DVAL_ID").First().Attribute("ID").Value;
                        // get name from syn
                        var b = descendant.Descendants("SYN").First().Value;

                        item.Values.Add(b, new ContextItem() { Name = b, ID = a });

                        idToDimensions.Add(a, id);
                    }

                    count++;
                }

                contextItems.Add(name, item);
            }
        }
開發者ID:obble80,項目名稱:Asiana,代碼行數:31,代碼來源:NavigationLinkBuilder.cs

示例8: Parse

        /// <summary>
        /// Parse a XElement type parameter to a ComplexTypeElement instance.
        /// </summary>
        /// <param name="complexTypeElement">A ComplexType element.</param>
        /// <returns>Returns a ComplexTypeElement instance.</returns>
        public static ComplexTypeElement Parse(XElement complexTypeElement)
        {
            if (null == complexTypeElement)
            {
                return null;
            }

            string name = null != complexTypeElement.Attribute("Name") ? complexTypeElement.Attribute("Name").Value : null;
            var props = new List<PropertyElement>();

            string xPath = "./*[local-name()='Property']";
            var propertyElements = complexTypeElement.XPathSelectElements(xPath, ODataNamespaceManager.Instance);

            foreach (var propEle in propertyElements)
            {
                if (null != propEle.Attribute("Name") && null != propEle.Attribute("Type"))
                {
                    AnnotationDVsManager accessor = AnnotationDVsManager.Instance();
                    string propertyName = string.Format("{0}_{1}", name, propEle.GetAttributeValue("Name"));
                    object defaultValue = accessor.GetDefaultValue(propertyName);
                    bool nullable = null != propEle.Attribute("Nullable") ? Convert.ToBoolean(propEle.Attribute("Nullable").Value) : true;
                    props.Add(new PropertyElement(propEle.Attribute("Name").Value.ToString(), propEle.Attribute("Type").Value.ToString(), defaultValue, nullable));
                }
            }

            return new ComplexTypeElement(name, props);
        }
開發者ID:RongfangWang,項目名稱:ValidationTool,代碼行數:32,代碼來源:ComplexTypeElement.cs

示例9: ReplaceInForms

        public void ReplaceInForms(string xPath, XElement document, Element previousParam, Element param)
        {
            var nodes = document.XPathSelectElements(xPath);

            foreach (var node in nodes)
            {
                if (node.HasElements)
                {
                    continue;
                }

                if (!node.HasAttributes || node.Attribute("Name").Value != previousParam.FormName || node.Attribute("Pdf").Value != previousParam.PdfName)
                {
                    continue;
                }

                AttributeHelper.AttributeInNode("Name", previousParam.FormName, param.FormName, node);
                AttributeHelper.AttributeInNode("Pdf", previousParam.PdfName, param.PdfName, node);
                AttributeHelper.AttributeInNode("Doctype", previousParam.Doctype, param.Doctype, node);
                AttributeHelper.AttributeInNode("DataNamePrefix", previousParam.DataNamePrefix, param.DataNamePrefix, node);
                AttributeHelper.AttributeInNode("Docdesc", previousParam.Docdesc, param.Docdesc, node);
                AttributeHelper.AttributeInNode("MergeID", previousParam.MergeId, param.MergeId, node);
                AttributeHelper.AttributeInNode("Attachment", previousParam.Attachment, param.Attachment, node);
            }
        }
開發者ID:reekroo,項目名稱:Configurator,代碼行數:25,代碼來源:Replace.cs

示例10: AddFrameXml

        /// <summary>
        /// Adds the frame XML.
        /// </summary>
        /// <param name="ui">The UI.</param>
        public void AddFrameXml(XElement ui)
        {
            if (ui == null)
                throw new ArgumentNullException("ui");

            // Select all elements in the FrameXML that has a name
            ui.XPathSelectElements("/descendant::*[@name]").ForEach(element => this.AddFrameXmlElement(element));
        }
開發者ID:jda808,項目名稱:NPL,代碼行數:12,代碼來源:FrameXmlDeclarationParser.cs

示例11: Parse

 public static LinkedInLikesSummary Parse(XElement xLikes) {
     return new LinkedInLikesSummary {
         Total = xLikes.GetAttributeValueOrDefault<int>("total"),
         Persons = (
             from xPerson in xLikes.XPathSelectElements("like/person")
             select LinkedInPersonSummary.Parse(xPerson)
         ).ToArray()
     };
 }
開發者ID:EmilMoe,項目名稱:Skybrud.Social,代碼行數:9,代碼來源:LinkedInLikesSummary.cs

示例12: AddToForms

        public void AddToForms(string xPath, XElement document, Element element)
        {
            var nodes = document.XPathSelectElements(xPath);

            foreach (var node in nodes)
            {
                node.Add(AttributeHelper.AddNodeToForm(element));
            }
        }
開發者ID:reekroo,項目名稱:Configurator,代碼行數:9,代碼來源:Add.cs

示例13: RemoveFromPackages

        public void RemoveFromPackages(string xPath, XElement document, Element param)
        {
            var nodes = document.XPathSelectElements(xPath);

            foreach (var node in nodes.Where(node => node.Name == "Form" && node.Attribute("Name") != null && node.Attribute("Name").Value == param.FormName))
            {
                node.Remove();
            }
        }
開發者ID:reekroo,項目名稱:Configurator,代碼行數:9,代碼來源:Remove.cs

示例14: RemoveFromPackage

        public void RemoveFromPackage(string xPath, XElement document, string package, string formName)
        {
            var nodes = document.XPathSelectElements(xPath);

            foreach (var node in nodes.Where(node => node.HasAttributes && node.Attribute("Name") != null && node.Attribute("Name").Value == formName &&
                                                     node.Parent.Parent.Attribute("Name").Value == package))
            {
                node.Remove();
            }
        }
開發者ID:reekroo,項目名稱:Configurator,代碼行數:10,代碼來源:Remove.cs

示例15: ReplaceInPdfs

        public void ReplaceInPdfs(string xPath, XElement document, Element previousParam, Element param)
        {
            var nodes = document.XPathSelectElements(xPath);

            foreach (var node in nodes.Where(node => node.HasAttributes && node.Attribute("Name").Value == previousParam.PdfName && node.Attribute("File").Value == previousParam.PdfFilePath))
            {
                    node.Attribute("Name").Value = param.PdfName;
                    node.Attribute("File").Value = param.PdfFilePath;
            }
        }
開發者ID:reekroo,項目名稱:Configurator,代碼行數:10,代碼來源:Replace.cs


注:本文中的System.Xml.Linq.XElement.XPathSelectElements方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。