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