public void IsComponent(Type type, bool expected) { // Arrange & Act var result = ViewComponentConventions.IsComponent(type.GetTypeInfo()); // Assert Assert.Equal(expected, result); }
/// <summary> /// Determines whether or not the given <see cref="TypeInfo"/> is a view component class. /// </summary> /// <param name="typeInfo">The <see cref="TypeInfo"/>.</param> /// <returns> /// <c>true</c> if <paramref name="typeInfo"/>represents a view component class, otherwise <c>false</c>. /// </returns> protected virtual bool IsViewComponentType(TypeInfo typeInfo) { if (typeInfo == null) { throw new ArgumentNullException(nameof(typeInfo)); } return(ViewComponentConventions.IsComponent(typeInfo)); }
/// <inheritdoc /> public void PopulateFeature(IEnumerable <ApplicationPart> parts, ViewComponentFeature feature) { if (parts == null) { throw new ArgumentNullException(nameof(parts)); } if (feature == null) { throw new ArgumentNullException(nameof(feature)); } foreach (var type in parts.OfType <IApplicationPartTypeProvider>().SelectMany(p => p.Types)) { if (ViewComponentConventions.IsComponent(type) && !feature.ViewComponents.Contains(type)) { feature.ViewComponents.Add(type); } } }