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


C# IEnumerable.Elements方法代码示例

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


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

示例1: GameParameters

 private GameParameters()
 {
     Path = System.Environment.CurrentDirectory;
     _xmlDoc = XDocument.Load(ParameterPath);
     _root = _xmlDoc.Descendants("GameParameters");
     Type = GameType.Classic;
     GameTime = Convert.ToInt32(_root.Elements("CommonParameter").Elements("GameTime").FirstOrDefault().Attribute("count").Value);
     Network = Network.Local;
     Theme = "Basic";
     _menutextureList = new Dictionary<string, BitmapImage>();
     ExplosionDelay = Convert.ToInt32(_root.Elements("CommonParameter").Elements("ExplosionDelay").FirstOrDefault().Attribute("count").Value);
     LoadAllSystemResources();
 }
开发者ID:SsSanzo,项目名称:BombEISTIv2,代码行数:13,代码来源:GameParameters.cs

示例2: GetVarfield

 public static string GetVarfield(IEnumerable<XElement> nodes, string id, string subfieldLabel)
 {
     var varfield =
         nodes.Elements("varfield").Where(x => ((string)x.Attribute("id")).Equals(id)).Elements("subfield");
     return
         varfield.Where(x => ((string)x.Attribute("label")).Equals(subfieldLabel)).Select(x => x.Value).FirstOrDefault();
 }
开发者ID:khellang,项目名称:Solvberget,代码行数:7,代码来源:MarcUtils.cs

示例3: GetMatchingSongIdElements

 private static IEnumerable<XElement> GetMatchingSongIdElements(IEnumerable<XElement> songs, string songId)
 {
     Debug.WriteLine(songs.Count());
     var songIdElements = songs.Elements("id");
     Debug.WriteLine("ids" + songIdElements.Count());
     var songIdElement = songIdElements.Where(el => el.Value.Equals(songId));
     return songIdElement;
 }
开发者ID:sihugh,项目名称:SongTagger,代码行数:8,代码来源:Parser.cs

示例4: LoadTasksForItem

 private IEnumerable<Task> LoadTasksForItem(IEnumerable<XElement> childrenElement, int parentId)
 {
     // Get the "child" elements of this element, which would be the tasks
     var tasks = childrenElement.Elements("child");
     if (tasks != null && tasks.Count() > 0)
     {
         foreach (var task in tasks)
         {
             yield return CreateTask(task, parentId);
         }
     }
 }
开发者ID:cerikpete,项目名称:AutismImporter,代码行数:12,代码来源:DocumentParser.cs

示例5: GetPdfInfos

        public static List<PdfInfo> GetPdfInfos(IEnumerable<XElement> pdfInfosElement)
        {
            IEnumerable<XElement> elements = pdfInfosElement.Elements("PdfInfo");
            var pdfInfos = new List<PdfInfo>();

            foreach (XElement element in elements)
            {
                // TODO validate by using a schema
                string filePrefix = element.Element("FilePrefix").Value;
                string folder = element.Element("Folder").Value;
                string textRegExPattern = element.Element("TextRegExPattern").Value;
                string dateRegExPattern = element.Element("DateRegExPattern").Value;

                var pdfInfo = new PdfInfo(filePrefix, folder, textRegExPattern, dateRegExPattern);
                pdfInfos.Add(pdfInfo);
            }

            return pdfInfos;
        }
开发者ID:openshac,项目名称:PdfFiler,代码行数:19,代码来源:RegexInfo.cs

示例6: LoadSettings

        //  Invoked from World.Settings
        internal static void LoadSettings(IEnumerable<XElement> xmlToolSettings)
        {
            foreach (var xElement in xmlToolSettings.Elements("Tool"))
            {
                string toolName = (string)xElement.Attribute("Name");

                switch (toolName)
                {
                    case "Paint":
                        _paintMode = (PaintMode)ToEnum(typeof(PaintMode), (string)xElement.Attribute("Mode") ?? PaintMode.TileAndWall.ToString());
                        break;
                    case "Brush":
                        _brushWidth = (int?)xElement.Attribute("Width") ?? 20;
                        _brushHeight = (int?)xElement.Attribute("Height") ?? 20;
                        _brushOutline = (int?)xElement.Attribute("Outline") ?? 1;
                        _brushShape = (BrushShape)ToEnum(typeof(BrushShape), (string)xElement.Attribute("Shape") ?? BrushShape.Square.ToString());
                        break;
                    case "Tile":
                        _paintTile = (int?)xElement.Attribute("Tile") ?? 0;
                        _paintTileMask = (int?)xElement.Attribute("Mask") ?? 0;
                        _paintTileActive = (bool)xElement.Attribute("Active");
                        _paintTileMaskMode = (MaskMode)ToEnum(typeof(MaskMode), (string)xElement.Attribute("Mode") ?? MaskMode.Off.ToString());
                        break;
                    case "Wall":
                        _paintWall = (int?)xElement.Attribute("Wall") ?? 0;
                        _paintWallMask = (int?)xElement.Attribute("Mask") ?? 0;
                        _paintWallActive = (bool)xElement.Attribute("Active");
                        _paintWallMaskMode = (MaskMode)ToEnum(typeof(MaskMode), (string)xElement.Attribute("Mode") ?? MaskMode.Off.ToString());
                        break;
                    case "Wire":
                        _redWire = (bool)xElement.Attribute("Red");
                        _blueWire = (bool)xElement.Attribute("Blue");
                        _greenWire = (bool)xElement.Attribute("Green");
                        break;
                }
            }
        }
开发者ID:liquidradio,项目名称:Terraria-Map-Editor,代码行数:38,代码来源:World.Settings.Tools.cs

示例7: GetActions

        public static bool GetActions(IEnumerable<XElement> actionsXml, out IList<IHttpAction> actions, out IList<IRequestAction> requestActions, out IList<IResponseAction> responseActions)
        {
            actions = new List<IHttpAction>();
            requestActions = new List<IRequestAction>();
            responseActions = new List<IResponseAction>();
            var actionsTemp = actions;
            Func<IList<IHttpAction>, IHttpAction, bool> addFunc = (a, ra) =>
                                                                     {
                                                                         a.Add(ra);
                                                                         return true;
                                                                     }; // hmm, this is just to keep the query below as a single statement, perhaps there is a better way?
            foreach (var ruleAction in from actionXml in actionsXml.Elements()
                                       let name = actionXml.Name.ToString()
                                       where RuleActionTypes.ContainsKey(name)
                                       let actionType = RuleActionTypes[name]
                                       where actionType != null
                                       let constructor = actionType.GetConstructor(new Type[] {})
                                       where constructor != null
                                       let ruleAction = (IHttpAction) constructor.Invoke(new object[] {})
                                       where ruleAction != null && addFunc(actionsTemp, ruleAction)
                                       where ruleAction.Deserialize(actionXml)
                                       select ruleAction)
            {
                if (ruleAction is IRequestAction)
                {
                    requestActions.Add((IRequestAction)ruleAction);
                }

                if (ruleAction is IResponseAction)
                {
                    responseActions.Add((IResponseAction)ruleAction);
                }
            }

            return true;
        }
开发者ID:bradrees,项目名称:HttpRules,代码行数:36,代码来源:RuleParser.cs

示例8: GetXElementByLocalName

 private IEnumerable<XElement> GetXElementByLocalName(IEnumerable<XElement> xElements, String eName)
 {
     if (xElements != null)
     {
         IEnumerable<XElement> returnValues = xElements.Where(x => x.Name.LocalName == eName);
         if (returnValues.Count() > 0)
             return returnValues;
         else if (xElements.Elements().Count() > 0)
             return GetXElementByLocalName(xElements.Elements(), eName);
     }
     return null;
 }
开发者ID:san90279,项目名称:UK_OAS,代码行数:12,代码来源:fmWCFServerWzdu.cs

示例9: GetFileNameElements

 private static IEnumerable<XElement> GetFileNameElements(string filename, IEnumerable<XElement> files)
 {
     var fileNameElement = files.Elements("name").Where(el => el.Value.Equals(filename));
     return fileNameElement;
 }
开发者ID:sihugh,项目名称:SongTagger,代码行数:5,代码来源:Parser.cs

示例10: GetVarfieldAsList

 protected static IEnumerable<string> GetVarfieldAsList(IEnumerable<XElement> nodes, string id,
                                                        string subfieldLabel)
 {
     var varfield =
         nodes.Elements("varfield").Where(x => ((string)x.Attribute("id")).Equals(id)).Elements("subfield");
     return varfield.Where(x => ((string)x.Attribute("label")).Equals(subfieldLabel)).Select(x => x.Value).ToList();
 }
开发者ID:digbib,项目名称:Solvberget,代码行数:7,代码来源:Document.cs

示例11: GetFixfield

        private static string GetFixfield(IEnumerable<XElement> nodes, string id, int fromPos, int toPos)
        {
            var fixfield = nodes.Elements("fixfield").Where(x => ((string)x.Attribute("id")).Equals(id)).Select(x => x.Value).FirstOrDefault();

            if (!string.IsNullOrEmpty(fixfield) && toPos < fixfield.Length)
            {
                if (fromPos == toPos)
                {
                    return fixfield.ElementAt(fromPos).ToString();
                }
                else
                {
                    return fixfield.Substring(fromPos, (toPos - fromPos) + 1);
                }
            }
            else
            {
                return "";
            }
        }
开发者ID:digbib,项目名称:Solvberget,代码行数:20,代码来源:Document.cs

示例12: FixRange

 // If the set of paragraphs from sourceDocument don't have a complete start/end for bookmarks,
 // comments, etc., then this adds them to the paragraph.  Note that this adds them to
 // sourceDocument, and is impure.
 private static void FixRange(XDocument sourceDocument, IEnumerable<XElement> newContent,
     XName startElement, XName endElement, XName idAttribute, XName refElement)
 {
     foreach (XElement start in newContent.DescendantsAndSelf(startElement))
     {
         string rangeId = start.Attribute(idAttribute).Value;
         if (newContent
             .DescendantsAndSelf(endElement)
             .Where(e => e.Attribute(idAttribute).Value == rangeId)
             .Count() == 0)
         {
             XElement end = sourceDocument
                 .Descendants(endElement)
                 .Where(o => o.Attribute(idAttribute).Value == rangeId)
                 .FirstOrDefault();
             if (end != null)
             {
                 AddAtEnd(newContent, new XElement(end));
                 if (refElement != null)
                 {
                     XElement newRef = new XElement(refElement, new XAttribute(idAttribute, rangeId));
                     AddAtEnd(newContent, new XElement(newRef));
                 }
             }
         }
     }
     foreach (XElement end in newContent.Elements(endElement))
     {
         string rangeId = end.Attribute(idAttribute).Value;
         if (newContent
             .DescendantsAndSelf(startElement)
             .Where(s => s.Attribute(idAttribute).Value == rangeId)
             .Count() == 0)
         {
             XElement start = sourceDocument
                 .Descendants(startElement)
                 .Where(o => o.Attribute(idAttribute).Value == rangeId)
                 .FirstOrDefault();
             if (start != null)
                 AddAtBeginning(newContent, new XElement(start));
         }
     }
 }
开发者ID:jecabana,项目名称:Portal-Vanity-Daniel-en-stand-by,代码行数:46,代码来源:DocumentBuilder.cs

示例13: ParseSchema

 public IEnumerable<XElement> ParseSchema(string tag, IEnumerable<XElement> data, XNamespace nsSchema)
 {
     var query = from e in data.Elements(nsSchema + tag)
                 select e;
     return query;
 }
开发者ID:interstellarspace,项目名称:XML_PARSER,代码行数:6,代码来源:EDMX.cs

示例14: AddPersonAttributes

        /// <summary>
        /// Adds the person attributes and values found in the XML to the person's attribute-value collection.
        /// </summary>
        /// <param name="groupMember"></param>
        /// <param name="attributes"></param>
        private void AddPersonAttributes( GroupMember groupMember, IEnumerable<XElement> attributes, RockContext rockContext )
        {
            // In order to add attributes to the person, you have to first load them all
            groupMember.Person.LoadAttributes( rockContext );

            foreach ( var personAttribute in attributes.Elements( "attribute" ) )
            {
                // Add them to the list of people who need to have their attribute values saved.
                // This will be done after all the family groups have been saved.
                _personWithAttributes[groupMember.Person.Guid] = true;
                foreach ( var pa in personAttribute.Attributes() )
                {
                    groupMember.Person.SetAttributeValue( pa.Name.LocalName, pa.Value );
                }
            }
        }
开发者ID:NewPointe,项目名称:Rockit,代码行数:21,代码来源:SampleData.ascx.cs

示例15: FixRange

 private static void FixRange(XDocument oldDoc, IEnumerable<XElement> paragraphs, XName startElement, XName endElement, XName idAttribute, XName refElement)
 {
     foreach (XElement start in paragraphs.Elements(startElement))
     {
         string rangeId = start.Attribute(idAttribute).Value;
         if (paragraphs.Elements(endElement).Where(e => e.Attribute(idAttribute).Value == rangeId).Count() == 0)
         {
             XElement end = oldDoc.Descendants().Elements(endElement).Where(o => o.Attribute(idAttribute).Value == rangeId).First();
             if (end != null)
             {
                 paragraphs.Last().Add(new XElement(end));
                 if (refElement != null)
                 {
                     XElement newRef = new XElement(refElement, new XAttribute(idAttribute, rangeId));
                     paragraphs.Last().Add(newRef);
                 }
             }
         }
     }
     foreach (XElement end in paragraphs.Elements(endElement))
     {
         string rangeId = end.Attribute(idAttribute).Value;
         if (paragraphs.Elements(startElement).Where(s => s.Attribute(idAttribute).Value == rangeId).Count() == 0)
         {
             XElement start = oldDoc.Descendants().Elements(startElement).Where(o => o.Attribute(idAttribute).Value == rangeId).First();
             if (start != null)
                 paragraphs.First().AddFirst(new XElement(start));
         }
     }
 }
开发者ID:huamouse,项目名称:Taoqi,代码行数:30,代码来源:DocumentBuilder.cs


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