Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions examples/Demo/Shared/Components/ApiDocumentation.razor
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
string header = Properties.Any(x => x.IsParameter) ? "Parameters" : "Properties";
<h4 id="@(_id + "_properties")">@header</h4>
<div class="docgrid">
<FluentDataGrid Items="@this.Properties.AsQueryable()" GridTemplateColumns="1fr 1fr 0.5fr 2fr">
<FluentDataGrid Items="@this.Properties.AsQueryable()" GridTemplateColumns="1fr 1fr 0.7fr 2fr">
<TemplateColumn Title="Name"><code>@context.Name</code></TemplateColumn>
<TemplateColumn Title="Type">
@context.Type
Expand Down Expand Up @@ -97,4 +97,4 @@
</FluentDataGrid>
</div>
}
</div>
</div>
16 changes: 15 additions & 1 deletion examples/Demo/Shared/Components/ApiDocumentation.razor.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System.Diagnostics.CodeAnalysis;
using System.Reflection;
using Microsoft.AspNetCore.Components;
using Microsoft.FluentUI.AspNetCore.Components;

namespace FluentUI.Demo.Shared.Components;

Expand Down Expand Up @@ -109,13 +110,26 @@ private IEnumerable<MemberDescription> GetMembers(MemberTypes type)
// Parameters/properties
if (!isEvent)
{
var defaultVaue = "";
if (propertyInfo.PropertyType.IsValueType || propertyInfo.PropertyType == typeof(string))
{
defaultVaue = obj?.GetType().GetProperty(propertyInfo.Name)?.GetValue(obj)?.ToString();
}
else if (propertyInfo.PropertyType == typeof(Icon))
{
if (obj?.GetType().GetProperty(propertyInfo.Name)?.GetValue(obj) is Icon icon)
{
defaultVaue = $"{icon.Variant}.{icon.Size}.{icon.Name}";
}
}

members.Add(new MemberDescription()
{
MemberType = MemberTypes.Property,
Name = propertyInfo.Name,
Type = propertyInfo.ToTypeNameString(),
EnumValues = GetEnumValues(propertyInfo),
Default = propertyInfo.PropertyType.IsValueType ? obj?.GetType().GetProperty(propertyInfo.Name)?.GetValue(obj)?.ToString() : "",
Default = defaultVaue,
Description = CodeComments.GetSummary(Component.Name + "." + propertyInfo.Name) ?? CodeComments.GetSummary(Component.BaseType?.Name + "." + propertyInfo.Name),
IsParameter = isParameter,
});
Expand Down