public void Close() { if (!IsConfigurationActive) { return; } this.IsConfigurationActive = false; if (_currentConfigurationTarget != null) { if (String.IsNullOrEmpty(_currentConfigurationTarget.Name)) { _currentConfigurationTarget.Name = "(untitled)"; } if (_filterQuery != null && _filterQuery.ToQuery() != _initialQuery) { _currentConfigurationTarget.FilterQuery = _filterQuery; } if (_completeCallback != null) { _completeCallback.OnNext(Unit.Default); _completeCallback.OnCompleted(); _completeCallback = null; } } TabManager.Save(); }
public string CreateFilterQuery() { switch (_option) { case SearchOption.Local: case SearchOption.CurrentTab: var pan = SplitPositiveNegativeQuery(_query); var query = pan.Item1.Select(s => "text contains " + s.EscapeForQuery().Quote()) .Concat( pan.Item2.Select(s => "!(text contains " + s.EscapeForQuery().Quote() + ")")) .JoinString("&&"); var ctab = TabManager.CurrentFocusTab; var ctf = ctab?.FilterQuery; if (_option != SearchOption.CurrentTab || ctf == null) { return("where " + query); } var cqf = QueryCompiler.CompileFilters(query); var filters = ctf.PredicateTreeRoot.Operator; var nfq = new FilterQuery { Sources = ctf.Sources.ToArray(), PredicateTreeRoot = new FilterExpressionRoot { Operator = filters.And(cqf.Operator) } }; return(nfq.ToQuery()); case SearchOption.Query: return(_filterQuery == null ? "!()" : _query); case SearchOption.Web: return("from search:" + _query.EscapeForQuery().Quote() + " where ()"); default: throw new ArgumentOutOfRangeException(); } }
public string CreateFilterQuery() { switch (_option) { case SearchOption.Local: case SearchOption.CurrentTab: var pan = SplitPositiveNegativeQuery(_query); var query = pan.Item1.Select(s => "text contains " + s.EscapeForQuery().Quote()) .Concat(pan.Item2.Select(s => "!(text contains " + s.EscapeForQuery().Quote() + ")")) .JoinString("&&"); var ctab = TabManager.CurrentFocusTab; var ctf = ctab != null ? ctab.FilterQuery : null; if (this._option != SearchOption.CurrentTab || ctf == null) { return "where " + query; } var cqf = QueryCompiler.CompileFilters(query); var filters = ctf.PredicateTreeRoot.Operator; var nfq = new FilterQuery { Sources = ctf.Sources.ToArray(), PredicateTreeRoot = new FilterExpressionRoot { Operator = filters.And(cqf.Operator) } }; return nfq.ToQuery(); case SearchOption.Query: return this._filterQuery == null ? "!()" : this._query; case SearchOption.Web: return "from search:" + this._query.EscapeForQuery().Quote() + " where ()"; default: throw new ArgumentOutOfRangeException(); } }