Ejemplo n.º 1
0
        void FillPhases(SearchStringParseResult result)
        {
            SearchModificator modificator    = SearchModificator.None;
            string            modificatorStr = string.Empty;

            switch (phaseState)
            {
            case PhaseState.Include:
                modificator    = SearchModificator.Include;
                modificatorStr = settings.IncludeModificator.ToString();
                break;

            case PhaseState.Exclude:
                modificator    = SearchModificator.Exclude;
                modificatorStr = settings.ExcludeModificator.ToString();
                break;
            }
            if (modificator != SearchModificator.None)
            {
                result.PhaseInfos.Add(new PhaseInfo(modificatorStr, modificator));
            }
            result.PhaseInfos.AddRange(GetFieldPhase());
            result.PhaseInfos.AddRange(GetPhase(modificator));
            if (hasSpace)
            {
                result.PhaseInfos.Add(new PhaseInfo(settings.PhaseSeparator.ToString()));
            }
        }
Ejemplo n.º 2
0
        SearchStringParseResult MakeResult()
        {
            var r = new SearchStringParseResult();

            FillSearchResult(r);
            FillPhases(r);
            return(r);
        }
Ejemplo n.º 3
0
        void ApplyAndFlush(SearchStringParseResult result)
        {
            if (DetectUnfinishedGroup())
            {
                FlushForUnfinishedGroup();
                return;
            }
            BoundaryValues();
            var r = MakeResult();

            result.Regular.AddRange(r.Regular);
            result.Exclude.AddRange(r.Exclude);
            result.Include.AddRange(r.Include);
            result.PhaseInfos.AddRange(r.PhaseInfos);
            FlushAll();
        }
Ejemplo n.º 4
0
        public SearchStringParseResult Parse(string searchText, SearchStringParseSettings settings)
        {
            SearchStringParseResult result = new SearchStringParseResult();

            if (searchText == null)
            {
                return(result);
            }
            this.settings = settings;
            state         = new ParsingState(searchText, settings);
            while (state.MoveNext())
            {
                switch (Add(state.CurrentChar.Value))
                {
                case SearchStringParseState.Completed:
                    ApplyAndFlush(result);
                    break;
                }
            }
            FlushAll();
            return(result);
        }
Ejemplo n.º 5
0
        void FillSearchResult(SearchStringParseResult result)
        {
            if (phase == string.Empty)
            {
                return;
            }
            var info = new SearchStringParseInfo(phase, field);

            switch (phaseState)
            {
            case PhaseState.None:
                result.Regular.Add(info);
                break;

            case PhaseState.Include:
                result.Include.Add(info);
                break;

            case PhaseState.Exclude:
                result.Exclude.Add(info);
                break;
            }
        }