예제 #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)))));
        }
예제 #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);
            }
        }
예제 #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)));
 }
예제 #4
0
 private CultureInfo GetBindingCulture(StepInstanceTemplate <TNativeSuggestionItem> stepInstanceTemplate)
 {
     return(GetBindingCulture(stepInstanceTemplate.Language));
 }
예제 #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);
 }