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


C# IXmlNode.IterateChildren方法代码示例

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


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

示例1: ParsePartwise

        private void ParsePartwise(IXmlNode element)
        {
            var version = element.GetAttribute("version");
            if (!string.IsNullOrEmpty(version) && version != "2.0")
            {
                throw new UnsupportedFormatException();
            }

            element.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "movement-title":
                            _score.Title = Std.GetNodeValue(c.FirstChild);
                            break;
                        case "identification":
                            ParseIdentification(c);
                            break;
                        case "part-list":
                            ParsePartList(c);
                            break;
                        case "part":
                            ParsePart(c);
                            break;
                    }
                }
            });
        }
开发者ID:eriser,项目名称:alphaTab,代码行数:30,代码来源:MusicXml2Importer.cs

示例2: GetNodeValue

 public static string GetNodeValue(IXmlNode n)
 {
     if (n.NodeType == XmlNodeType.Element || n.NodeType == XmlNodeType.Document)
     {
         var txt = new StringBuilder();
         n.IterateChildren(c =>
         {
             txt.Append(GetNodeValue(c));
         });
         return txt.ToString().Trim();
     }
     return n.Value;
 }
开发者ID:piotrwarzocha,项目名称:alphaTab,代码行数:13,代码来源:Std.cs

示例3: ParseTime

 private void ParseTime(IXmlNode element, MasterBar masterBar)
 {
     element.IterateChildren(c =>
     {
         if (c.NodeType == XmlNodeType.Element)
         {
             switch (c.LocalName)
             {
                 case "beats":
                     masterBar.TimeSignatureNumerator = Std.ParseInt(Std.GetNodeValue(c));
                     break;
                 case "beats-type":
                     masterBar.TimeSignatureDenominator = Std.ParseInt(Std.GetNodeValue(c));
                     break;
             }
         }
     });
 }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:18,代码来源:MusicXml2Importer.cs

示例4: ParsePitch

        private void ParsePitch(IXmlNode element, Track track, Beat beat, Note note)
        {
            string step = null;
            int semitones = 0;
            int octave = 0;
            element.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "step":
                            step = Std.GetNodeValue(c);
                            break;
                        case "alter":
                            semitones = Std.ParseInt(Std.GetNodeValue(c));
                            break;
                        case "octave":
                            // 0-9, 4 for middle C
                            octave = Std.ParseInt(Std.GetNodeValue(c));
                            break;
                    }
                }
            });

            var fullNoteName = step + octave;
            var fullNoteValue = TuningParser.GetTuningForText(fullNoteName) + semitones;

            ApplyNoteStringFrets(track, beat, note, fullNoteValue);
        }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:30,代码来源:MusicXml2Importer.cs

示例5: ParsePart

 private void ParsePart(IXmlNode element)
 {
     var id = element.GetAttribute("id");
     var track = _trackById[id];
     var isFirstMeasure = true;
     element.IterateChildren(c =>
     {
         if (c.NodeType == XmlNodeType.Element)
         {
             switch (c.LocalName)
             {
                 case "measure":
                     ParseMeasure(c, track, isFirstMeasure);
                     isFirstMeasure = false;
                     break;
             }
         }
     });
 }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:19,代码来源:MusicXml2Importer.cs

示例6: ParseNotations

 private void ParseNotations(IXmlNode element, Beat beat, Note note)
 {
     element.IterateChildren(c =>
     {
         if (c.NodeType == XmlNodeType.Element)
         {
             switch (c.LocalName)
             {
                 case "tied":
                     ParseTied(c, note);
                     break;
                 case "slide":
                     if (c.GetAttribute("type") == "start")
                     {
                         note.SlideType = SlideType.Legato;
                     }
                     break;
                 case "dynamics":
                     ParseDynamics(c, beat);
                     break;
             }
         }
     });
 }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:24,代码来源:MusicXml2Importer.cs

示例7: ParseMeasure

        private void ParseMeasure(IXmlNode element, Track track, bool isFirstMeasure)
        {
            var barIndex = 0;
            if (isFirstMeasure)
            {
                _trackFirstMeasureNumber = Std.ParseInt(element.GetAttribute("number"));
                barIndex = 0;
            }
            else
            {
                barIndex = Std.ParseInt(element.GetAttribute("number")) - _trackFirstMeasureNumber;
            }

            // create empty bars to the current index
            Bar bar = null;
            MasterBar masterBar = null;
            for (int i = track.Staves[0].Bars.Count; i <= barIndex; i++)
            {
                bar = new Bar();
                masterBar = GetOrCreateMasterBar(barIndex);
                track.AddBarToStaff(0, bar);

                for (int j = 0; j < _maxVoices; j++)
                {
                    var emptyVoice = new Voice();
                    bar.AddVoice(emptyVoice);
                    var emptyBeat = new Beat { IsEmpty = true };
                    emptyVoice.AddBeat(emptyBeat);
                }
            }

            bool chord = false;
            bool isFirstBeat = true;

            element.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "note":
                            chord = ParseNoteBeat(c, track, bar, chord, isFirstBeat);
                            isFirstBeat = false;
                            break;
                        case "forward":
                            break;
                        case "direction":
                            ParseDirection(c, masterBar);
                            break;
                        case "attributes":
                            ParseAttributes(c, bar, masterBar);
                            break;
                        case "harmony":
                            // TODO
                            break;
                        case "sound":
                            // TODO
                            break;
                        case "barline":
                            // TODO
                            break;
                    }
                }
            });
        }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:65,代码来源:MusicXml2Importer.cs

示例8: ParseIdentification

 private void ParseIdentification(IXmlNode element)
 {
     element.IterateChildren(c =>
     {
         if (c.NodeType == XmlNodeType.Element)
         {
             switch (c.LocalName)
             {
                 case "creator":
                     if (c.GetAttribute("type") == "composer")
                     {
                         _score.Music = Std.GetNodeValue(c.FirstChild);
                     }
                     break;
                 case "rights":
                     _score.Artist = Std.GetNodeValue(c.FirstChild);
                     break;
             }
         }
     });
 }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:21,代码来源:MusicXml2Importer.cs

示例9: ParseBeats

 //
 // <Beats>...</Beats>
 //
 private void ParseBeats(IXmlNode node)
 {
     node.IterateChildren(c =>
     {
         if (c.NodeType == XmlNodeType.Element)
         {
             switch (c.LocalName)
             {
                 case "Beat":
                     ParseBeat(c);
                     break;
             }
         }
     });
 }
开发者ID:rkenning,项目名称:alphaTab,代码行数:18,代码来源:GpxParser.cs

示例10: ParseBeatProperties

        private void ParseBeatProperties(IXmlNode node, Beat beat)
        {
            bool isWhammy = false;
            BendPoint whammyOrigin = null;
            int? whammyMiddleValue = null;
            int? whammyMiddleOffset1 = null;
            int? whammyMiddleOffset2 = null;
            BendPoint whammyDestination = null;

            node.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "Property":
                            var name = c.Attributes.Get("name").Value;
                            switch (name)
                            {
                                case "Brush":
                                    if (GetValue(FindChildElement(c, "Direction")) == "Up")
                                    {
                                        beat.BrushType = BrushType.BrushUp;
                                    }
                                    else
                                    {
                                        beat.BrushType = BrushType.BrushDown;
                                    }
                                    break;
                                // TODO: brush duration
                                case "PickStroke":
                                    if (GetValue(FindChildElement(c, "Direction")) == "Up")
                                    {
                                        beat.PickStroke = PickStrokeType.Up;
                                    }
                                    else
                                    {
                                        beat.PickStroke = PickStrokeType.Down;
                                    }
                                    break;
                                // TODO: brush duration
                                case "Slapped":
                                    if (FindChildElement(c, "Enable") != null)
                                        beat.Slap = true;
                                    break;
                                case "Popped":
                                    if (FindChildElement(c, "Enable") != null)
                                        beat.Pop = true;
                                    break;
                                case "VibratoWTremBar":
                                    switch (GetValue(FindChildElement(c, "Strength")))
                                    {
                                        case "Wide":
                                            beat.Vibrato = VibratoType.Wide;
                                            break;
                                        case "Slight":
                                            beat.Vibrato = VibratoType.Slight;
                                            break;
                                    }
                                    break;
                                case "WhammyBar":
                                    isWhammy = true;
                                    break;
                                case "WhammyBarExtend":

                                case "WhammyBarOriginValue":
                                    if (whammyOrigin == null) whammyOrigin = new BendPoint();
                                    whammyOrigin.Value = ToBendValue(Std.ParseFloat(GetValue(FindChildElement(c, "Float"))));
                                    break;
                                case "WhammyBarOriginOffset":
                                    if (whammyOrigin == null) whammyOrigin = new BendPoint();
                                    whammyOrigin.Offset = ToBendOffset(Std.ParseFloat(GetValue(FindChildElement(c, "Float"))));
                                    break;

                                case "WhammyBarMiddleValue":
                                    whammyMiddleValue = ToBendValue(Std.ParseFloat(GetValue(FindChildElement(c, "Float"))));
                                    break;

                                case "WhammyBarMiddleOffset1":
                                    whammyMiddleOffset1 = ToBendOffset(Std.ParseFloat(GetValue(FindChildElement(c, "Float"))));
                                    break;
                                case "WhammyBarMiddleOffset2":
                                    whammyMiddleOffset2 = ToBendOffset(Std.ParseFloat(GetValue(FindChildElement(c, "Float"))));
                                    break;

                                case "WhammyBarDestinationValue":
                                    if (whammyDestination == null)
                                        whammyDestination = new BendPoint(BendPoint.MaxPosition);
                                    whammyDestination.Value = ToBendValue(Std.ParseFloat(GetValue(FindChildElement(c, "Float"))));
                                    break;

                                case "WhammyBarDestinationOffset":
                                    if (whammyDestination == null) whammyDestination = new BendPoint();
                                    whammyDestination.Offset = ToBendOffset(Std.ParseFloat(GetValue(FindChildElement(c, "Float"))));

                                    break;
                            }
                            break;
                    }
                }
//.........这里部分代码省略.........
开发者ID:rkenning,项目名称:alphaTab,代码行数:101,代码来源:GpxParser.cs

示例11: ParseBeat

        private void ParseBeat(IXmlNode node)
        {
            var beat = new Beat();
            var beatId = node.Attributes.Get("id").Value;

            node.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "Notes":
                            _notesOfBeat[beatId] = GetValue(c).Split(' ');
                            break;
                        case "Rhythm":
                            _rhythmOfBeat[beatId] = c.Attributes.Get("ref").Value;
                            break;
                        case "Fadding":
                            if (GetValue(c) == "FadeIn")
                            {
                                beat.FadeIn = true;
                            }
                            break;
                        case "Tremolo":
                            switch (GetValue(c))
                            {
                                case "1/2":
                                    beat.TremoloSpeed = Duration.Eighth;
                                    break;
                                case "1/4":
                                    beat.TremoloSpeed = Duration.Sixteenth;
                                    break;
                                case "1/8":
                                    beat.TremoloSpeed = Duration.ThirtySecond;
                                    break;
                            }
                            break;
                        case "Chord":
                            beat.ChordId = GetValue(c);
                            break;
                        case "Hairpin":
                            switch (GetValue(c))
                            {
                                case "Crescendo":
                                    beat.Crescendo = CrescendoType.Crescendo;
                                    break;
                                case "Decrescendo":
                                    beat.Crescendo = CrescendoType.Decrescendo;
                                    break;
                            }
                            break;
                        case "Arpeggio":
                            if (GetValue(c) == "Up")
                            {
                                beat.BrushType = BrushType.ArpeggioUp;
                            }
                            else
                            {
                                beat.BrushType = BrushType.ArpeggioDown;
                            }
                            break;
                        // TODO: brushDuration
                        case "Properties":
                            ParseBeatProperties(c, beat);
                            break;
                        case "FreeText":
                            beat.Text = GetValue(c);
                            break;
                        case "Dynamic":
                            switch (GetValue(c))
                            {
                                case "PPP":
                                    beat.Dynamic = DynamicValue.PPP;
                                    break;
                                case "PP":
                                    beat.Dynamic = DynamicValue.PP;
                                    break;
                                case "P":
                                    beat.Dynamic = DynamicValue.P;
                                    break;
                                case "MP":
                                    beat.Dynamic = DynamicValue.MP;
                                    break;
                                case "MF":
                                    beat.Dynamic = DynamicValue.MF;
                                    break;
                                case "F":
                                    beat.Dynamic = DynamicValue.F;
                                    break;
                                case "FF":
                                    beat.Dynamic = DynamicValue.FF;
                                    break;
                                case "FFF":
                                    beat.Dynamic = DynamicValue.FFF;
                                    break;
                            }
                            break;
                        case "GraceNotes":
                            switch (GetValue(c))
                            {
//.........这里部分代码省略.........
开发者ID:rkenning,项目名称:alphaTab,代码行数:101,代码来源:GpxParser.cs

示例12: ParseBar

        private void ParseBar(IXmlNode node)
        {
            var bar = new Bar();
            var barId = node.Attributes.Get("id").Value;

            node.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "Voices":
                            _voicesOfBar[barId] = GetValue(c).Split(' ');
                            break;
                        case "Clef":
                            switch (GetValue(c))
                            {
                                case "Neutral":
                                    bar.Clef = Clef.Neutral;
                                    break;
                                case "G2":
                                    bar.Clef = Clef.G2;
                                    break;
                                case "F4":
                                    bar.Clef = Clef.F4;
                                    break;
                                case "C4":
                                    bar.Clef = Clef.C4;
                                    break;
                                case "C3":
                                    bar.Clef = Clef.C3;
                                    break;
                            }
                            break;
                            // case "SimileMark":
                    }
                }
            });

            _barsById[barId] = bar;
        }
开发者ID:rkenning,项目名称:alphaTab,代码行数:41,代码来源:GpxParser.cs

示例13: ParseAutomations

 private void ParseAutomations(IXmlNode node)
 {
     node.IterateChildren(c =>
     {
         if (c.NodeType == XmlNodeType.Element)
         {
             switch (c.LocalName)
             {
                 case "Automation":
                     ParseAutomation(c);
                     break;
             }
         }
     });
 }
开发者ID:rkenning,项目名称:alphaTab,代码行数:15,代码来源:GpxParser.cs

示例14: ParseAutomation

        private void ParseAutomation(IXmlNode node)
        {
            string type = null;
            bool isLinear = false;
            string barId = null;
            float ratioPosition = 0;
            float value = 0;
            int reference = 0;
            string text = null;

            node.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "Type":
                            type = GetValue(c);
                            break;
                        case "Linear":
                            isLinear = GetValue(c).ToLower() == "true";
                            break;
                        case "Bar":
                            barId = GetValue(c);
                            break;
                        case "Position":
                            ratioPosition = Std.ParseFloat(GetValue(c));
                            break;
                        case "Value":
                            var parts = GetValue(c).Split(' ');
                            value = Std.ParseFloat(parts[0]);
                            reference = Std.ParseInt(parts[1]);
                            break;
                        case "Text":
                            text = GetValue(c);
                            break;
                    }
                }
            });

            if (type == null) return;
            Automation automation = null;
            switch (type)
            {
                case "Tempo":
                    automation = Automation.BuildTempoAutomation(isLinear, ratioPosition, value, reference);
                    break;
                    // TODO: other automations
            }

            if (automation != null)
            {
                automation.Text = text;
            }

            if (barId != null)
            {
                if (!_automations.ContainsKey(barId))
                {
                    _automations[barId] = new FastList<Automation>();
                }
                _automations[barId].Add(automation);
            }
        }
开发者ID:rkenning,项目名称:alphaTab,代码行数:64,代码来源:GpxParser.cs

示例15: ParseVoice

        private void ParseVoice(IXmlNode node)
        {
            var voice = new Voice();
            var voiceId = node.Attributes.Get("id").Value;

            node.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "Beats":
                            _beatsOfVoice[voiceId] = GetValue(c).Split(' ');
                            break;
                    }
                }
            });

            _voiceById[voiceId] = voice;
        }
开发者ID:rkenning,项目名称:alphaTab,代码行数:20,代码来源:GpxParser.cs


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