public void IsComponent(Type type, bool expected) { // Arrange & Act var result = ViewComponentConventions.IsComponent(type.GetTypeInfo()); // Assert Assert.Equal(expected, result); }
public void GetComponentFullName(Type type, string expected) { // Arrange & Act var result = ViewComponentConventions.GetComponentFullName(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)); }
private static ViewComponentDescriptor CreateDescriptor(TypeInfo typeInfo) { var candidate = new ViewComponentDescriptor { FullName = ViewComponentConventions.GetComponentFullName(typeInfo), ShortName = ViewComponentConventions.GetComponentName(typeInfo), TypeInfo = typeInfo, MethodInfo = FindMethod(typeInfo.AsType()) }; return(candidate); }
/// <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); } } }