// Methods public ActionResult <FeaturesViewModel> Index() { // FeaturesViewModel var viewModel = new FeaturesViewModel(); { // ControllerFeature var controllerFeature = new ControllerFeature(); _applicationPartManager.PopulateFeature(controllerFeature); viewModel.Controllers = controllerFeature.Controllers.Select(x => x.FullName).ToList(); // TagHelperFeature var tagHelperFeature = new TagHelperFeature(); _applicationPartManager.PopulateFeature(tagHelperFeature); viewModel.TagHelpers = tagHelperFeature.TagHelpers.Select(x => x.FullName).ToList(); // ViewComponentFeature var viewComponentFeature = new ViewComponentFeature(); _applicationPartManager.PopulateFeature(viewComponentFeature); viewModel.ViewComponents = viewComponentFeature.ViewComponents.Select(x => x.FullName).ToList(); } // Return return(viewModel); }
public IActionResult Index() { var viewModel = new FeaturesViewModel(); var controllerFeature = new ControllerFeature(); _partManager.PopulateFeature(controllerFeature); viewModel.Controllers = controllerFeature.Controllers.ToList(); var tagHelperFeature = new TagHelperFeature(); _partManager.PopulateFeature(tagHelperFeature); viewModel.TagHelpers = tagHelperFeature.TagHelpers.ToList(); var viewComponentFeature = new ViewComponentFeature(); _partManager.PopulateFeature(viewComponentFeature); viewModel.ViewComponents = viewComponentFeature.ViewComponents.ToList(); var feature = new ViewsFeature(); _partManager.PopulateFeature(feature); viewModel.Views = feature.ViewDescriptors.Select(v => v.Type.GetTypeInfo()).ToList(); return(View(viewModel)); }
public IActionResult Index() { var viewModel = new FeaturesViewModel(); var controllerFeature = new ControllerFeature(); _partManager.PopulateFeature(controllerFeature); viewModel.Controllers = controllerFeature.Controllers.ToList(); var metaDataReferenceFeature = new MetadataReferenceFeature(); _partManager.PopulateFeature(metaDataReferenceFeature); viewModel.MetadataReferences = metaDataReferenceFeature.MetadataReferences .ToList(); var tagHelperFeature = new TagHelperFeature(); _partManager.PopulateFeature(tagHelperFeature); viewModel.TagHelpers = tagHelperFeature.TagHelpers.ToList(); var viewComponentFeature = new ViewComponentFeature(); _partManager.PopulateFeature(viewComponentFeature); viewModel.ViewComponents = viewComponentFeature.ViewComponents.ToList(); return(View(viewModel)); }
//public static IList<CodeAnalysis.MetadataReference> MetadataReferences(this ApplicationPartManager applicationPartManager) { // var feature = new MetadataReferenceFeature(); // applicationPartManager.PopulateFeature(feature); // return feature.MetadataReferences; //} public static IList <TypeInfo> TagHelpers(this ApplicationPartManager applicationPartManager) { var feature = new TagHelperFeature(); applicationPartManager.PopulateFeature(feature); return(feature.TagHelpers); }
public Task StartAsync(CancellationToken cancellationToken) { // Get the names of all the application parts. This is the short assembly name for AssemblyParts var applicationParts = _partManager.ApplicationParts.Select(x => x.Name); var controllerFeature = new ControllerFeature(); _partManager.PopulateFeature(controllerFeature); var controllers = controllerFeature.Controllers.Select(x => x.Name); var tagHelperFeature = new TagHelperFeature(); _partManager.PopulateFeature(tagHelperFeature); var tagHelpers = tagHelperFeature.TagHelpers.Select(x => x.Name); var viewComponentFeature = new ViewComponentFeature(); _partManager.PopulateFeature(viewComponentFeature); var viewComponents = viewComponentFeature.ViewComponents.Select(x => x.Name); var viewsFeature = new ViewsFeature(); _partManager.PopulateFeature(viewsFeature); var views = viewsFeature.ViewDescriptors.Select(x => x.RelativePath); //Log the application parts _logger.LogInformation("Found the following Application Parts: " + Environment.NewLine + string.Join(Environment.NewLine, applicationParts)); _logger.LogInformation("Found the following Controllers: " + Environment.NewLine + string.Join(Environment.NewLine, controllers)); _logger.LogInformation("Found the following Views: " + Environment.NewLine + string.Join(Environment.NewLine, views)); _logger.LogInformation("Found the following Tag Helpers: " + Environment.NewLine + string.Join(Environment.NewLine, tagHelpers)); _logger.LogInformation("Found the following View Components: " + Environment.NewLine + string.Join(Environment.NewLine, viewComponents)); return(Task.CompletedTask); }
/// <summary> /// Initializes a new <see cref="FeatureTagHelperTypeResolver"/> instance. /// </summary> /// <param name="manager">The <see cref="ApplicationPartManager"/> of the application.</param> public WeeFeatureTagHelperTypeResolver(ApplicationPartManager manager) { if (manager == null) { throw new ArgumentNullException(nameof(manager)); } _feature = new TagHelperFeature(); manager.PopulateFeature(_feature); }
public AssemblyNameGlobbingTagHelperTypeResolver(ApplicationPartManager manager) { if (manager == null) { throw new ArgumentNullException(nameof(manager)); } Feature = new TagHelperFeature(); manager.PopulateFeature(Feature); }
public AspNetOptions AddTagHelpers() { if (_parts != null) { var feature = new TagHelperFeature(); _parts.PopulateFeature(feature); var viewComponentTypes = feature.TagHelpers.Select(v => v.AsType()); _registration.Sources(sources => sources.AddTypes(viewComponentTypes)); } _registration.Select((selector, publicOnly) => selector.AddClasses(x => x.AssignableTo <PageModel>(), publicOnly) .UsingRegistrationStrategy(RegistrationStrategy.Skip) .AsSelf()); return(this); }
private void EnsureMatchings() { if (_matchings != null) { return; } lock (this) { if (_matchings == null) { var feature = new TagHelperFeature(); _partManager.PopulateFeature(feature); var matchings = new List <LiquidTagHelperMatching>(); foreach (var tagHelper in feature.TagHelpers) { var matching = _allMatchings.GetOrAdd(tagHelper.AsType(), type => { var descriptorBuilder = TagHelperDescriptorBuilder.Create( type.FullName, type.Assembly.GetName().Name); descriptorBuilder.SetTypeName(type.FullName); AddTagMatchingRules(type, descriptorBuilder); var descriptor = descriptorBuilder.Build(); return(new LiquidTagHelperMatching( descriptor.Name, descriptor.AssemblyName, descriptor.TagMatchingRules )); }); matchings.Add(matching); } _matchings = matchings; } } }
public static void AddTagHelpersAsServices(ApplicationPartManager manager, IServiceCollection services) { if (manager == null) { throw new ArgumentNullException(nameof(manager)); } if (services == null) { throw new ArgumentNullException(nameof(services)); } var feature = new TagHelperFeature(); manager.PopulateFeature(feature); foreach (var type in feature.TagHelpers.Select(t => t.AsType())) { services.TryAddTransient(type, type); } services.Replace(ServiceDescriptor.Transient <ITagHelperActivator, ServiceBasedTagHelperActivator>()); }
public static void AddTagHelpersAsServices(ApplicationPartManager manager, IServiceCollection services) { if (manager == null) { throw new ArgumentNullException(nameof(manager)); } if (services == null) { throw new ArgumentNullException(nameof(services)); } var feature = new TagHelperFeature(); manager.PopulateFeature(feature); foreach (var type in feature.TagHelpers.Select(t => t.AsType())) { services.TryAddTransient(type, type); } services.Replace(ServiceDescriptor.Transient<ITagHelperActivator, ServiceBasedTagHelperActivator>()); services.Replace(ServiceDescriptor.Transient<ITagHelperTypeResolver, FeatureTagHelperTypeResolver>()); }
public Task StartAsync(CancellationToken cancellationToken) { // Get the names of all the application parts. This is the short assembly name for AssemblyParts var applicationPartNames = _partManager.ApplicationParts.Select(x => x.Name).ToList(); // Create a controller feature, and populate it from the application parts var controllerFeature = new ControllerFeature(); _partManager.PopulateFeature(controllerFeature); // Get the names of all of the controllers var controllerNames = controllerFeature.Controllers.Select(x => x.Name).ToList(); // Create a view feature, and populate it from the application parts var viewComponentFeatures = new ViewComponentFeature(); _partManager.PopulateFeature(viewComponentFeatures); // Get the names of all of the view components var viewComponentNames = viewComponentFeatures.ViewComponents.Select(x => x.Name).ToList(); // Create a razor views feature, and populate it from the application parts var razorViewFeatures = new ViewsFeature(); _partManager.PopulateFeature(razorViewFeatures); // Get the names of all of the razor views var razorViewsNames = razorViewFeatures.ViewDescriptors.Select(x => x.RelativePath).ToList(); // Create a view feature, and populate it from the application parts var tagHelperFeatures = new TagHelperFeature(); _partManager.PopulateFeature(tagHelperFeatures); // Get the names of all of the views var tagHelperNames = tagHelperFeatures.TagHelpers.Select(x => x.Name).ToList(); // Log the controllers if (applicationPartNames.Any()) { _logger.LogInformation($"Found the following application parts: '{string.Join(", ", applicationPartNames)}'"); } // Log the controllers if (controllerNames.Any()) { _logger.LogInformation($"Found the following controllers: '{string.Join(", ", controllerNames)}'"); } // Log the controllers if (viewComponentNames.Any()) { _logger.LogInformation($"Found the following view components: '{string.Join(", ", viewComponentNames)}'"); } // Log the razor views if (razorViewsNames.Any()) { _logger.LogInformation($"Found the following razor views: '{string.Join(", ", razorViewsNames)}'"); } // Log the tag helpers if (tagHelperNames.Any()) { _logger.LogInformation($"Found the following tag helpers: '{string.Join(", ", tagHelperNames)}'"); } return(Task.CompletedTask); }