Beispiel #1
0
        public void AddStepInstanceTemplate(StepInstanceTemplate <TNativeSuggestionItem> stepInstanceTemplate)
        {
            var matchingItems = GetMatchingBindings(stepInstanceTemplate);

            AddStepSuggestionToMatchingItems(stepInstanceTemplate.StepDefinitionType, matchingItems,
                                             item => item.AddSuggestion(
                                                 new BoundInstanceTemplate <TNativeSuggestionItem>(
                                                     stepInstanceTemplate,
                                                     nativeSuggestionItemFactory,
                                                     stepInstanceTemplate.Instances.Where(s => item.StepBinding == null || s.Match(item.StepBinding, GetBindingCulture(s), true, BindingMatchService)))));
        }
Beispiel #2
0
        private void RemoveStepInstanceTemplate(StepInstanceTemplate <TNativeSuggestionItem> stepInstanceTemplate)
        {
            var matchingItems = GetMatchingBindings(stepInstanceTemplate).Append(notMatchingSteps[stepInstanceTemplate.StepDefinitionType]);

            var boundInstanceTemplates = matchingItems.SelectMany(item => item.Suggestions)
                                         .OfType <BoundInstanceTemplate <TNativeSuggestionItem> >()
                                         .Where(bt => bt.Template == stepInstanceTemplate);

            foreach (var boundInstanceTemplate in boundInstanceTemplates.ToArray())
            {
                RemoveBoundStepSuggestion(boundInstanceTemplate);
            }
        }
Beispiel #3
0
 private IEnumerable <BoundStepSuggestions <TNativeSuggestionItem> > GetMatchingBindings(StepInstanceTemplate <TNativeSuggestionItem> stepInstanceTemplate)
 {
     //TODO: optimize
     return(boundStepSuggestions.GetPotentialItemsByPrefix(stepInstanceTemplate.StepPrefix).Where(it => stepInstanceTemplate.Match(it.StepBinding, GetBindingCulture(stepInstanceTemplate), true, BindingMatchService)));
 }
Beispiel #4
0
 private CultureInfo GetBindingCulture(StepInstanceTemplate <TNativeSuggestionItem> stepInstanceTemplate)
 {
     return(GetBindingCulture(stepInstanceTemplate.Language));
 }
Beispiel #5
0
 public BoundInstanceTemplate(StepInstanceTemplate <TNativeSuggestionItem> template, INativeSuggestionItemFactory <TNativeSuggestionItem> nativeSuggestionItemFactory, IEnumerable <IBoundStepSuggestion <TNativeSuggestionItem> > suggestions)
 {
     Template             = template;
     this.suggestions     = new StepSuggestionList <TNativeSuggestionItem>(nativeSuggestionItemFactory, suggestions);
     NativeSuggestionItem = nativeSuggestionItemFactory.CloneTo(template.NativeSuggestionItem, this);
 }