public void LoadFromXML(XDocument doc) { foreach (var a in doc.Root.Attributes()) { switch (a.Name.LocalName) { case "rating": Rating = Convert.ToInt32(a.Value); break; case "description": Description = a.Value; break; case "style": Style = a.Value; break; case "difficulty": Difficulty = a.Value; break; } } foreach (var e in doc.Root.Elements()) { if (e.Name.LocalName == "stepdata") { foreach (var x in e.Elements()) { ArrowData.Add(e.ToArrow()); } } else if (e.Name.LocalName == "freezedata") { foreach (var x in e.Elements()) { FreezeData.Add(e.ToArrow()); } } } }
public int LoadFromData(string[] data, int pointer) { string s = ""; Style = data[pointer++].Replace("dance-", "").TrimEnd(':'); Style = Style[0].ToString().ToUpper() + Style.Substring(1); Description = data[pointer++].TrimEnd(':'); Difficulty = data[pointer++].TrimEnd(':'); Difficulty = Difficulty[0].ToString().ToUpper() + Difficulty.Substring(1); Rating = Convert.ToInt32(data[pointer++].TrimEnd(':')); pointer++; List <string> measure = new List <string>(); List <string> allData = new List <string>(); while (s != ";") { measure.Clear(); s = data[pointer++]; while (s != "," && s != ";") { measure.Add(s); allData.Add(s); s = data[pointer++]; } switch (measure.Count) { case 4: for (int i = 0; i < 4; i++) { ArrowData.Add(measure[i].ToArrow()); for (int j = 0; j < 3; j++) { ArrowData.Add(Arrow.None); } } break; case 8: for (int i = 0; i < 8; i++) { ArrowData.Add(measure[i].ToArrow()); ArrowData.Add(Arrow.None); } break; case 12: for (int i = 0; i < 4; i++) { ArrowData.Add(Arrow.All); ArrowData.Add(measure[i * 3].ToArrow()); ArrowData.Add(measure[i * 3 + 1].ToArrow()); ArrowData.Add(measure[i * 3 + 2].ToArrow()); } break; case 16: for (int i = 0; i < 16; i++) { ArrowData.Add(measure[i].ToArrow()); } break; } } Arrow freezesOn = Arrow.None; foreach (var a in allData) { FreezeData.Add(a.ToFreeze(freezesOn, out freezesOn)); } return(pointer); }