public static IEnumerable<FieldAndTerm> GetCurrentFieldsAndTerms(string text) { var editor = new QueryEditor {Text = text}; var textSnapshotReader = editor.ActiveView.GetReader(); string currentField = null; while (!textSnapshotReader.IsAtSnapshotEnd) { var token = textSnapshotReader.ReadToken(); if (token == null) break; var txt = textSnapshotReader.ReadTextReverse(token.Length); textSnapshotReader.ReadToken(); if(string.IsNullOrWhiteSpace(txt)) continue; string currentVal = null; if (txt.EndsWith(":")) { currentField = txt.Substring(0, txt.Length - 1); } else { currentVal = txt; } if (currentField == null || currentVal == null) continue; yield return new FieldAndTerm(currentField, currentVal); currentField = null; } }
public static IEnumerable <FieldAndTerm> GetCurrentFieldsAndTerms(string text) { var editor = new QueryEditor { Text = text }; var textSnapshotReader = editor.ActiveView.GetReader(); string currentField = null; while (!textSnapshotReader.IsAtSnapshotEnd) { var token = textSnapshotReader.ReadToken(); if (token == null) { break; } var txt = textSnapshotReader.ReadTextReverse(token.Length); textSnapshotReader.ReadToken(); if (string.IsNullOrWhiteSpace(txt)) { continue; } string currentVal = null; if (txt.EndsWith(":")) { currentField = txt.Substring(0, txt.Length - 1); } else { currentVal = txt; } if (currentField == null || currentVal == null) { continue; } yield return(new FieldAndTerm(currentField, currentVal)); currentField = null; } }