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