public ITextStructureNavigator CreateTextStructureNavigator(ITextBuffer textBuffer, IContentType contentType) { if (textBuffer is null) { throw new ArgumentNullException(nameof(textBuffer)); } if (contentType is null) { throw new ArgumentNullException(nameof(contentType)); } if (providerSelector is null) { providerSelector = new ProviderSelector <ITextStructureNavigatorProvider, IContentTypeMetadata>(contentTypeRegistryService, textStructureNavigatorProviders); } foreach (var p in providerSelector.GetProviders(contentType)) { var nav = p.Value.CreateTextStructureNavigator(textBuffer); if (nav is not null) { return(nav); } } Debug.Fail($"Couldn't find a {nameof(ITextStructureNavigatorProvider)}"); return(new TextStructureNavigator(textBuffer, contentTypeRegistryService.UnknownContentType)); }
public ITextParagraphPropertiesFactoryService Select(IContentType contentType) { if (providerSelector == null) { providerSelector = new ProviderSelector <ITextParagraphPropertiesFactoryService, IContentTypeMetadata>(contentTypeRegistryService, textParagraphPropertiesFactoryServices); } return(providerSelector.GetProviders(contentType).FirstOrDefault()?.Value); }
ITextViewModel CreateTextViewModel(ITextDataModel dataModel, ITextViewRoleSet roles) { if (providerSelector is null) { providerSelector = new ProviderSelector <ITextViewModelProvider, IContentTypeAndTextViewRoleMetadata>(contentTypeRegistryService, textViewModelProviders); } var contentType = dataModel.ContentType; foreach (var p in providerSelector.GetProviders(contentType)) { var model = p.Value.CreateTextViewModel(dataModel, roles); if (!(model is null)) { return(model); } } return(new TextViewModel(dataModel)); }