本文整理汇总了C#中System.Xml.XmlElement.IterateChildren方法的典型用法代码示例。如果您正苦于以下问题:C# XmlElement.IterateChildren方法的具体用法?C# XmlElement.IterateChildren怎么用?C# XmlElement.IterateChildren使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Xml.XmlElement
的用法示例。
在下文中一共展示了XmlElement.IterateChildren方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ParsePitch
private void ParsePitch(XmlElement element, Track track, Beat beat, Note note)
{
string step = null;
int semitones = 0;
int octave = 0;
element.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
var e = (XmlElement)c;
switch (c.LocalName)
{
case "step":
step = Std.GetNodeValue(e);
break;
case "alter":
semitones = Std.ParseInt(Std.GetNodeValue(e));
break;
case "octave":
// 0-9, 4 for middle C
octave = Std.ParseInt(Std.GetNodeValue(e));
break;
}
}
});
var fullNoteName = step + octave;
var fullNoteValue = TuningParser.GetTuningForText(fullNoteName) + semitones;
ApplyNoteStringFrets(track, beat, note, fullNoteValue);
}
示例2: ParseScorePart
private void ParseScorePart(XmlElement element)
{
string id = element.GetAttribute("id");
var track = new Track();
_trackById[id] = track;
_score.AddTrack(track);
element.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
var e = (XmlElement)c;
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(e, track);
break;
}
}
});
if (track.Tuning == null || track.Tuning.Length == 0)
{
track.Tuning = Tuning.GetDefaultTuningFor(6).Tunings;
}
}
示例3: ParseClef
private void ParseClef(XmlElement element, Bar bar)
{
string sign = null;
string line = null;
element.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
var e = (XmlElement)c;
switch (c.LocalName)
{
case "sign":
sign = Std.GetNodeValue(e);
break;
case "line":
line = Std.GetNodeValue(e);
break;
}
}
});
var clef = sign + line;
switch (clef)
{
case "G2":
bar.Clef = Clef.G2;
break;
case "F4":
bar.Clef = Clef.F4;
break;
case "C3":
bar.Clef = Clef.C3;
break;
case "C4":
bar.Clef = Clef.C4;
break;
}
}
示例4: ParsePartwise
private void ParsePartwise(XmlElement element)
{
var version = element.GetAttribute("version");
if (!string.IsNullOrEmpty(version) && version != "2.0")
{
throw new UnsupportedFormatException();
}
element.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
var e = (XmlElement)c;
switch (c.LocalName)
{
case "movement-title":
_score.Title = Std.GetNodeValue(c.FirstChild);
break;
case "identification":
ParseIdentification(e);
break;
case "part-list":
ParsePartList(e);
break;
case "part":
ParsePart(e);
break;
}
}
});
}
示例5: ParseVoice
private void ParseVoice(XmlElement node)
{
var voice = new Voice();
var voiceId = node.Attributes["id"].Value;
node.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
switch (c.LocalName)
{
case "Beats":
_beatsOfVoice[voiceId] = GetValue(c).Split(' ');
break;
}
}
});
_voiceById[voiceId] = voice;
}
示例6: ParseBeat
private void ParseBeat(XmlElement node)
{
var beat = new Beat();
var beatId = node.Attributes["id"].Value;
node.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
XmlElement e = (XmlElement) c;
switch (c.LocalName)
{
case "Notes":
_notesOfBeat[beatId] = GetValue(c).Split(' ');
break;
case "Rhythm":
_rhythmOfBeat[beatId] = e.Attributes["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))
//.........这里部分代码省略.........
示例7: ParseMidiInstrument
private void ParseMidiInstrument(XmlElement element, Track track)
{
element.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
var e = (XmlElement)c;
switch (c.LocalName)
{
case "midi-channel":
track.PlaybackInfo.PrimaryChannel = Std.ParseInt(Std.GetNodeValue(c.FirstChild));
break;
case "midi-program":
track.PlaybackInfo.Program = Std.ParseInt(Std.GetNodeValue(c.FirstChild));
break;
case "midi-volume":
track.PlaybackInfo.Volume = Std.ParseInt(Std.GetNodeValue(c.FirstChild));
break;
}
}
});
}
示例8: ParseRhythm
private void ParseRhythm(XmlElement node)
{
var rhythm = new GpxRhythm();
var rhythmId = node.Attributes["id"].Value;
node.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
XmlElement e = (XmlElement) c;
switch (c.LocalName)
{
case "NoteValue":
switch (GetValue(c))
{
// case "Long":
// case "DoubleWhole":
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;
// case "128th":
// case "256th":
break;
}
break;
case "PrimaryTuplet":
rhythm.TupletNumerator = Std.ParseInt(e.Attributes["num"].Value);
rhythm.TupletDenominator = Std.ParseInt(e.Attributes["den"].Value);
break;
case "AugmentationDot":
rhythm.Dots = Std.ParseInt(e.Attributes["count"].Value);
break;
}
}
});
_rhythmById[rhythmId] = rhythm;
}
示例9: ParseKey
private void ParseKey(XmlElement element, MasterBar masterBar)
{
int fifths = int.MinValue;
int keyStep = int.MinValue;
int keyAlter = int.MinValue;
element.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
var e = (XmlElement)c;
switch (c.LocalName)
{
case "fifths":
fifths = Std.ParseInt(Std.GetNodeValue(e));
break;
case "key-step":
keyStep = Std.ParseInt(Std.GetNodeValue(e));
break;
case "key-alter":
keyAlter = Std.ParseInt(Std.GetNodeValue(e));
break;
}
}
});
if (fifths != int.MinValue)
{
// TODO: check if this is conrrect
masterBar.KeySignature = fifths;
}
else
{
// TODO: map keyStep/keyAlter to internal keysignature
}
}
示例10: ParseMeasure
private void ParseMeasure(XmlElement 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.Bars.Count; i <= barIndex; i++)
{
bar = new Bar();
masterBar = GetOrCreateMasterBar(barIndex);
track.AddBar(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)
{
var e = (XmlElement)c;
switch (c.LocalName)
{
case "note":
chord = ParseNoteBeat(e, track, bar, chord, isFirstBeat);
isFirstBeat = false;
break;
case "forward":
break;
case "direction":
ParseDirection(e, masterBar);
break;
case "attributes":
ParseAttributes(e, bar, masterBar);
break;
case "harmony":
// TODO
break;
case "sound":
// TODO
break;
case "barline":
// TODO
break;
}
}
});
}
示例11: ParseIdentification
private void ParseIdentification(XmlElement element)
{
element.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
var e = (XmlElement)c;
switch (c.LocalName)
{
case "creator":
if (e.GetAttribute("type") == "composer")
{
_score.Music = Std.GetNodeValue(c.FirstChild);
}
break;
case "rights":
_score.Artist = Std.GetNodeValue(c.FirstChild);
break;
}
}
});
}
示例12: ParseDynamics
private void ParseDynamics(XmlElement element, Beat beat)
{
element.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
switch (c.LocalName)
{
case "p":
beat.Dynamic = DynamicValue.P;
break;
case "pp":
beat.Dynamic = DynamicValue.PP;
break;
case "ppp":
beat.Dynamic = DynamicValue.PPP;
break;
case "f":
beat.Dynamic = DynamicValue.F;
break;
case "ff":
beat.Dynamic = DynamicValue.FF;
break;
case "fff":
beat.Dynamic = DynamicValue.FFF;
break;
case "mp":
beat.Dynamic = DynamicValue.MP;
break;
case "mf":
beat.Dynamic = DynamicValue.MF;
break;
}
}
});
}
示例13: ParseDirection
private void ParseDirection(XmlElement element, MasterBar masterBar)
{
element.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
var e = (XmlElement)c;
switch (c.LocalName)
{
case "sound":
var tempoAutomation = new Automation();
tempoAutomation.IsLinear = true;
tempoAutomation.Type = AutomationType.Tempo;
tempoAutomation.Value = Std.ParseInt(e.GetAttribute("tempo"));
masterBar.TempoAutomation = tempoAutomation;
break;
}
}
});
}
示例14: ParseTime
private void ParseTime(XmlElement element, MasterBar masterBar)
{
element.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
var e = (XmlElement)c;
switch (c.LocalName)
{
case "beats":
masterBar.TimeSignatureNumerator = Std.ParseInt(Std.GetNodeValue(e));
break;
case "beats-type":
masterBar.TimeSignatureDenominator = Std.ParseInt(Std.GetNodeValue(e));
break;
}
}
});
}
示例15: ParseNotations
private void ParseNotations(XmlElement element, Beat beat, Note note)
{
element.IterateChildren(c =>
{
if (c.NodeType == XmlNodeType.Element)
{
var e = (XmlElement)c;
switch (c.LocalName)
{
case "tied":
ParseTied(e, note);
break;
case "slide":
if (e.GetAttribute("type") == "start")
{
note.SlideType = SlideType.Legato;
}
break;
case "dynamics":
ParseDynamics(e, beat);
break;
}
}
});
}