internal bool PreserveWhiteSpace(Processor proc, XPathNavigator node) { // last one should win. I.E. We starting from the end. I.E. Lowest priority should go first if (_whitespaceList != null) { for (int i = _whitespaceList.Count - 1; 0 <= i; i--) { WhitespaceElement elem = (WhitespaceElement)_whitespaceList[i]; if (proc.Matches(node, elem.Key)) { return(elem.PreserveSpace); } } } if (_imports != null) { for (int importIndex = _imports.Count - 1; importIndex >= 0; importIndex--) { Stylesheet stylesheet = (Stylesheet)_imports[importIndex]; if (!stylesheet.PreserveWhiteSpace(proc, node)) { return(false); } } } return(true); }
private IEnumerable <BaseElement> ProcessLine(string line) { var songTokens = Regex.Matches(line, @"([\s/]*)([^\s/]*)"); BaseElement element = null; foreach (Match token in songTokens) { int index = 0; foreach (Group g in token.Groups) { if (index != 0) { BaseElement previousElement = element; if (!string.IsNullOrWhiteSpace(g.Value)) { var rawChord = ParseExact(g.Value); if (rawChord != null) { var chord = new Chord(rawChord); element = new ChordElement(chord); } else { element = new WordElement(g.Value); } } else { element = new WhitespaceElement(g.Value); } element.PreviousElement = previousElement; if (previousElement != null) { previousElement.NextElement = element; } yield return(element); } index++; } } }
internal void AddSpace(Compiler compiler, String query, double Priority, bool PreserveSpace) { WhitespaceElement elem; if (this.queryKeyTable != null) { if (this.queryKeyTable.Contains(query)) { elem = (WhitespaceElement) this.queryKeyTable[query]; elem.ReplaceValue(PreserveSpace); return; } } else{ this.queryKeyTable = new Hashtable(); this.whitespaceList = new ArrayList(); } int key = compiler.AddQuery(query); elem = new WhitespaceElement(key, Priority, PreserveSpace); this.queryKeyTable[query] = elem; this.whitespaceList.Add(elem); }
internal void AddSpace(Compiler compiler, String query, double Priority, bool PreserveSpace) { WhitespaceElement elem; if (_queryKeyTable != null) { if (_queryKeyTable.Contains(query)) { elem = (WhitespaceElement)_queryKeyTable[query]; elem.ReplaceValue(PreserveSpace); return; } } else { _queryKeyTable = new Hashtable(); _whitespaceList = new ArrayList(); } int key = compiler.AddQuery(query); elem = new WhitespaceElement(key, Priority, PreserveSpace); _queryKeyTable[query] = elem; _whitespaceList.Add(elem); }