private void BuildLines() { XElement Lines = this.doc.Root.Element(this.Namespace + "Lines"); Lines.Elements().Remove(); foreach (var Translation in this.lines) { foreach (var CurrentLine in Translation.Value) { string Start = this.SecondsToTimestamp(CurrentLine.StartTime); string End = this.SecondsToTimestamp(CurrentLine.EndTime); var Line = from e in Lines.Descendants() where e.HasAttributeWithValue("Start", Start) && e.HasAttributeWithValue("End", End) select e; XElement TargetLine = null; if (Line.Count() == 0) { TargetLine = new XElement(this.Namespace + "Line", new XAttribute("Start", Start), new XAttribute("End", End) ); Lines.Add(TargetLine); } else { TargetLine = Line.First(); } TargetLine.Add(new XElement(this.Namespace + "Translation", new XAttribute("ID", Translation.Key), CurrentLine.Text )); } } }
void Awake() { instance = this; }