mirror of https://github.com/abpframework/abp.git
committed by
GitHub
30 changed files with 340 additions and 22 deletions
@ -0,0 +1,32 @@ |
|||||
|
@using System.Reflection |
||||
|
|
||||
|
@model List<PropertyInfo> |
||||
|
|
||||
|
<h4>Properties</h4> |
||||
|
|
||||
|
<ul> |
||||
|
@foreach (var property in Model) |
||||
|
{ |
||||
|
<li> |
||||
|
<strong>@property.Name</strong> |
||||
|
@{ |
||||
|
var typeName = property.PropertyType.Name; |
||||
|
if (property.PropertyType.IsGenericType && property.PropertyType.GetGenericTypeDefinition() == typeof(Nullable<>)) |
||||
|
{ |
||||
|
typeName = property.PropertyType.GetGenericArguments()[0].Name; |
||||
|
} |
||||
|
} |
||||
|
(<code>@typeName</code>) |
||||
|
@if (property.PropertyType.IsEnum) |
||||
|
{ |
||||
|
<ul> |
||||
|
<li> |
||||
|
<span class="text-muted"> |
||||
|
[ @string.Join(", ", Enum.GetNames(property.PropertyType)) ] |
||||
|
</span> |
||||
|
</li> |
||||
|
</ul> |
||||
|
} |
||||
|
</li> |
||||
|
} |
||||
|
</ul> |
||||
@ -0,0 +1,30 @@ |
|||||
|
using System; |
||||
|
using System.Collections.Generic; |
||||
|
using System.Reflection; |
||||
|
using Microsoft.AspNetCore.Mvc; |
||||
|
using Microsoft.AspNetCore.Mvc.RazorPages; |
||||
|
using Microsoft.AspNetCore.Razor.TagHelpers; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers; |
||||
|
using Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.TagHelpers.Card; |
||||
|
|
||||
|
namespace Volo.Abp.AspNetCore.Mvc.UI.Bootstrap.Demo.Components.TagHelperProperties; |
||||
|
|
||||
|
public class TagHelperPropertiesViewComponent : AbpViewComponent |
||||
|
{ |
||||
|
public List<PropertyInfo> Properties { get; } = new(); |
||||
|
public IViewComponentResult Invoke(Type type) |
||||
|
{ |
||||
|
foreach (var property in type.GetRuntimeProperties()) |
||||
|
{ |
||||
|
if (typeof(AbpTagHelper).IsAssignableFrom(property.DeclaringType) && |
||||
|
property.GetCustomAttribute<HtmlAttributeNotBoundAttribute>() == null && |
||||
|
!property.PropertyType.IsAbstract && |
||||
|
property.GetMethod?.IsPublic == true) |
||||
|
{ |
||||
|
Properties.Add(property); |
||||
|
} |
||||
|
} |
||||
|
|
||||
|
return View("/Components/TagHelperProperties/Default.cshtml", Properties); |
||||
|
} |
||||
|
} |
||||
Loading…
Reference in new issue