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


C# IXmlNode.GetAttribute方法代码示例

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


在下文中一共展示了IXmlNode.GetAttribute方法的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: ParseTied

 private static void ParseTied(IXmlNode element, Note note)
 {
     if (element.GetAttribute("type") == "start")
     {
         note.IsTieOrigin = true;
     }
     else
     {
         note.IsTieDestination = true;
     }
 }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:11,代码来源:MusicXml2Importer.cs

示例3: ParseScorePart

        private void ParseScorePart(IXmlNode element)
        {
            string id = element.GetAttribute("id");
            var track = new Track(1);
            _trackById[id] = track;
            _score.AddTrack(track);
            element.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "part-name":
                            track.Name = Std.GetNodeValue(c.FirstChild);
                            break;
                        case "part-abbreviation":
                            track.ShortName = Std.GetNodeValue(c.FirstChild);
                            break;
                        case "midi-instrument":
                            ParseMidiInstrument(c, track);
                            break;
                    }
                }
            });

            if (track.Tuning == null || track.Tuning.Length == 0)
            {
                track.Tuning = Tuning.GetDefaultTuningFor(6).Tunings;
            }
        }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:30,代码来源:MusicXml2Importer.cs

示例4: 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

示例5: 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

示例6: ParseNote

        private void ParseNote(IXmlNode node)
        {
            var note = new Note();
            var noteId = node.GetAttribute("id");

            node.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "Properties":
                            ParseNoteProperties(c, note, noteId);
                            break;
                        case "AntiAccent":
                            if (GetValue(c).ToLower() == "normal")
                            {
                                note.IsGhost = true;
                            }
                            break;
                        case "LetRing":
                            note.IsLetRing = true;
                            break;
                        case "Trill":
                            note.TrillValue = Std.ParseInt(GetValue(c));
                            note.TrillSpeed = Duration.Sixteenth;
                            break;
                        case "Accent":
                            var accentFlags = Std.ParseInt(GetValue(c));
                            if ((accentFlags & 0x01) != 0)
                                note.IsStaccato = true;
                            if ((accentFlags & 0x04) != 0)
                                note.Accentuated = AccentuationType.Heavy;
                            if ((accentFlags & 0x08) != 0)
                                note.Accentuated = AccentuationType.Normal;
                            break;
                        case "Tie":
                            if (c.GetAttribute("origin").ToLower() == "true")
                            {
                                note.IsTieOrigin = true;
                            }
                            if (c.GetAttribute("destination").ToLower() == "true")
                            {
                                note.IsTieDestination = true;
                            }
                            break;
                        case "Vibrato":
                            switch (GetValue(c))
                            {
                                case "Slight":
                                    note.Vibrato = VibratoType.Slight;
                                    break;
                                case "Wide":
                                    note.Vibrato = VibratoType.Wide;
                                    break;
                            }
                            break;
                        case "LeftFingering":
                            note.IsFingering = true;
                            switch (GetValue(c))
                            {
                                case "P":
                                    note.LeftHandFinger = Fingers.Thumb;
                                    break;
                                case "I":
                                    note.LeftHandFinger = Fingers.IndexFinger;
                                    break;
                                case "M":
                                    note.LeftHandFinger = Fingers.MiddleFinger;
                                    break;
                                case "A":
                                    note.LeftHandFinger = Fingers.AnnularFinger;
                                    break;
                                case "C":
                                    note.LeftHandFinger = Fingers.LittleFinger;
                                    break;
                            }
                            break;
                        case "RightFingering":
                            note.IsFingering = true;
                            switch (GetValue(c))
                            {
                                case "P":
                                    note.RightHandFinger = Fingers.Thumb;
                                    break;
                                case "I":
                                    note.RightHandFinger = Fingers.IndexFinger;
                                    break;
                                case "M":
                                    note.RightHandFinger = Fingers.MiddleFinger;
                                    break;
                                case "A":
                                    note.RightHandFinger = Fingers.AnnularFinger;
                                    break;
                                case "C":
                                    note.RightHandFinger = Fingers.LittleFinger;
                                    break;
                            }
                            break;
                    }
//.........这里部分代码省略.........
开发者ID:CoderLine,项目名称:alphaTab,代码行数:101,代码来源:GpxParser.cs

示例7: ParseGeneralMidi

        private void ParseGeneralMidi(Track track, IXmlNode node)
        {
            track.PlaybackInfo.Port = Std.ParseInt(GetValue(FindChildElement(node, "Port")));
            track.PlaybackInfo.Program = Std.ParseInt(GetValue(FindChildElement(node, "Program")));
            track.PlaybackInfo.PrimaryChannel = Std.ParseInt(GetValue(FindChildElement(node, "PrimaryChannel")));
            track.PlaybackInfo.SecondaryChannel = Std.ParseInt(GetValue(FindChildElement(node, "SecondaryChannel")));

            track.IsPercussion = node.GetAttribute("table") == "Percussion";
        }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:9,代码来源:GpxParser.cs

示例8: ParseDiagramItem

 private void ParseDiagramItem(Track track, IXmlNode node)
 {
     var chord = new Chord();
     var chordId = node.GetAttribute("id");
     chord.Name = node.GetAttribute("name");
     track.Chords[chordId] = chord;
 }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:7,代码来源:GpxParser.cs

示例9: ParseBeat

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

            node.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "Notes":
                            _notesOfBeat[beatId] = GetValue(c).Split(' ');
                            break;
                        case "Rhythm":
                            _rhythmOfBeat[beatId] = c.GetAttribute("ref");
                            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 "XProperties":
                            ParseBeatXProperties(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;
//.........这里部分代码省略.........
开发者ID:CoderLine,项目名称:alphaTab,代码行数:101,代码来源:GpxParser.cs

示例10: ParseBar

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

            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:CoderLine,项目名称:alphaTab,代码行数:41,代码来源:GpxParser.cs

示例11: ParseVoice

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

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

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

示例12: ParseTrackProperty

 private void ParseTrackProperty(Track track, IXmlNode node)
 {
     var propertyName = node.GetAttribute("name");
     switch (propertyName)
     {
         case "Tuning":
             var tuningParts = GetValue(FindChildElement(node, "Pitches")).Split(' ');
             var tuning = new int[tuningParts.Length];
             for (int i = 0; i < tuning.Length; i++)
             {
                 tuning[tuning.Length - 1 - i] = Std.ParseInt(tuningParts[i]);
             }
             track.Tuning = tuning;
             break;
         case "DiagramCollection":
             ParseDiagramCollection(track, node);
             break;
         case "CapoFret":
             track.Capo = Std.ParseInt(GetValue(FindChildElement(node, "Fret")));
             break;
     }
 }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:22,代码来源:GpxParser.cs

示例13: ParseTrack

        private void ParseTrack(IXmlNode node)
        {
            var track = new Track(1);
            var trackId = node.GetAttribute("id");

            node.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "Name":
                            track.Name = GetValue(c);
                            break;
                        case "Instrument":
                            var instrumentName = c.GetAttribute("ref");
                            if (instrumentName.EndsWith("-gs") || instrumentName.EndsWith("GrandStaff"))
                            {
                                track.EnsureStaveCount(2);
                            }
                            break;
                        case "ShortName":
                            track.ShortName = GetValue(c);
                            break;
                        //TODO: case "Lyrics": parseLyrics(track, c);
                        case "Properties":
                            ParseTrackProperties(track, c);
                            break;
                        case "GeneralMidi":
                            ParseGeneralMidi(track, c);
                            break;
                        case "PlaybackState":
                            var state = GetValue(c);
                            track.PlaybackInfo.IsSolo = state == "Solo";
                            track.PlaybackInfo.IsMute = state == "Mute";
                            break;
                    }
                }
            });

            _tracksById[trackId] = track;
        }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:42,代码来源:GpxParser.cs

示例14: ParseRhythm

        private void ParseRhythm(IXmlNode node)
        {
            var rhythm = new GpxRhythm();
            var rhythmId = node.GetAttribute("id");
            node.IterateChildren(c =>
            {
                if (c.NodeType == XmlNodeType.Element)
                {
                    switch (c.LocalName)
                    {
                        case "NoteValue":
                            switch (GetValue(c))
                            {
                                case "Long":
                                    rhythm.Value = Duration.QuadrupleWhole;
                                    break;
                                case "DoubleWhole":
                                    rhythm.Value = Duration.DoubleWhole;
                                    break;
                                case "Whole":
                                    rhythm.Value = Duration.Whole;
                                    break;
                                case "Half":
                                    rhythm.Value = Duration.Half;
                                    break;
                                case "Quarter":
                                    rhythm.Value = Duration.Quarter;
                                    break;
                                case "Eighth":
                                    rhythm.Value = Duration.Eighth;
                                    break;
                                case "16th":
                                    rhythm.Value = Duration.Sixteenth;
                                    break;
                                case "32nd":
                                    rhythm.Value = Duration.ThirtySecond;
                                    break;
                                case "64th":
                                    rhythm.Value = Duration.SixtyFourth;
                                    break;
                                case "128th":
                                    rhythm.Value = Duration.OneHundredTwentyEighth;
                                    break;
                                case "256th":
                                    rhythm.Value = Duration.TwoHundredFiftySixth;
                                    break;
                            }
                            break;
                        case "PrimaryTuplet":
                            rhythm.TupletNumerator = Std.ParseInt(c.GetAttribute("num"));
                            rhythm.TupletDenominator = Std.ParseInt(c.GetAttribute("den"));
                            break;
                        case "AugmentationDot":
                            rhythm.Dots = Std.ParseInt(c.GetAttribute("count"));
                            break;
                    }
                }
            });

            _rhythmById[rhythmId] = rhythm;
        }
开发者ID:CoderLine,项目名称:alphaTab,代码行数:61,代码来源:GpxParser.cs

示例15: TryGetReference

		public bool TryGetReference(IXmlNode node, out int id)
		{
			var text = node.GetAttribute(XRef.Ref);
			return int.TryParse(text, IntegerStyle, Culture, out id);
		}
开发者ID:leloulight,项目名称:Core,代码行数:5,代码来源:DefaultXmlReferenceFormat.cs


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