Ejemplo n.º 1
0
        private string GetSuggestionText(StepBindingNew stepBinding)
        {
            string suggestionTextBase = stepBinding.Regex == null ? "[...]" :
                                        "[" + RegexSampler.GetRegexSample(stepBinding.Regex.ToString(), stepBinding.Method.Parameters.Select(p => p.ParameterName).ToArray()) + "]";

            return(string.Format("{0} -> {1}", suggestionTextBase, stepBinding.Method.ShortDisplayText));
        }
Ejemplo n.º 2
0
        private string GetInsertionText(StepBindingNew stepBinding)
        {
            if (stepBinding.Regex == null)
            {
                return("...");
            }

            var paramNames = stepBinding.Method.Parameters.Select(p => p.ParameterName);

            return(RegexSampler.GetRegexSample(stepBinding.Regex.ToString(), paramNames.ToArray()));
        }
Ejemplo n.º 3
0
        public BoundStepSuggestions(StepBindingNew stepBinding, INativeSuggestionItemFactory <TNativeSuggestionItem> nativeSuggestionItemFactory)
        {
            if (stepBinding == null)
            {
                throw new ArgumentNullException("stepBinding");
            }

            StepBinding = stepBinding;
            BindingType = stepBinding.BindingType;
            string suggestionText = GetSuggestionText(stepBinding);

            NativeSuggestionItem = nativeSuggestionItemFactory.Create(suggestionText, GetInsertionText(StepBinding), 0, BindingType.ToString().Substring(0, 1) + "-b", this);
            suggestions          = new StepSuggestionList <TNativeSuggestionItem>(nativeSuggestionItemFactory);
        }
Ejemplo n.º 4
0
        public bool Match(StepBindingNew binding, bool includeRegexCheck, IBindingMatchService bindingMatchService)
        {
            if (binding.BindingType != BindingType)
            {
                return(false);
            }

            if (instances.Count == 0)
            {
                return(false);
            }

            return(instances.Any(i => i.Match(binding, true, bindingMatchService)));
        }
Ejemplo n.º 5
0
        public void RemoveBinding(StepBindingNew stepBinding)
        {
            var item = boundStepSuggestions.GetRelatedItems(stepBinding.Regex).FirstOrDefault(it => it.StepBinding == stepBinding);

            if (item == null)
            {
                return;
            }

            foreach (var stepSuggestion in item.Suggestions.ToArray())
            {
                item.RemoveSuggestion(stepSuggestion);
                if (!stepSuggestion.MatchGroups.Any())
                {
                    notMatchingSteps[item.BindingType].AddSuggestion(stepSuggestion);
                }
            }

            boundStepSuggestions.Remove(item);
        }
Ejemplo n.º 6
0
        public void AddBinding(StepBindingNew stepBinding)
        {
            var item = new BoundStepSuggestions <TNativeSuggestionItem>(stepBinding, nativeSuggestionItemFactory);

            var affectedSuggestions = new List <IBoundStepSuggestion <TNativeSuggestionItem> >(
                boundStepSuggestions.GetRelatedItems(stepBinding.Regex).SelectMany(relatedItem => relatedItem.Suggestions).Where(s => s.Match(stepBinding, true, BindingMatchService)));

            affectedSuggestions.AddRange(notMatchingSteps[item.BindingType].Suggestions.Where(s => s.Match(stepBinding, true, BindingMatchService)));

            foreach (var affectedSuggestion in affectedSuggestions)
            {
                RemoveBoundStepSuggestion(affectedSuggestion);
            }

            boundStepSuggestions.Add(item);

            foreach (var affectedSuggestion in affectedSuggestions)
            {
                AddStepSuggestion(affectedSuggestion);
            }
        }
Ejemplo n.º 7
0
 public bool Match(StepBindingNew binding, bool includeRegexCheck, IBindingMatchService bindingMatchService)
 {
     return(bindingMatchService.Match(binding, this, useRegexMatching: includeRegexCheck, useParamMatching: false).Success);
 }
Ejemplo n.º 8
0
 public BindingMatchNew(StepBindingNew stepBinding, int scopeMatches)
 {
     StepBinding  = stepBinding;
     ScopeMatches = scopeMatches;
 }