Skip to content

Commit

Permalink
InternalTypeDoc - fallback - find type containing the specified type …
Browse files Browse the repository at this point in the history
…name
  • Loading branch information
Harvey1214 committed Nov 10, 2023
1 parent da0af6f commit a17d2b8
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Havit.Blazor.Documentation/Pages/InternalTypeDoc.razor.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ protected override void OnParametersSet()
{
try
{
type = ApiTypeHelper.GetType(TypeText);
type = ApiTypeHelper.GetType(TypeText, true);
}
catch
{
Expand Down
15 changes: 14 additions & 1 deletion Havit.Blazor.Documentation/Services/ApiHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ public static bool IsDelegate(Type type)
return typeof(Delegate).IsAssignableFrom(type);
}

public static Type GetType(string typeName)
public static Type GetType(string typeName, bool includeTypesContainingTypeName = false)
{
Type result;

Expand Down Expand Up @@ -71,6 +71,19 @@ public static Type GetType(string typeName)
}
catch { }

if (includeTypesContainingTypeName)
{
try
{
result = typeof(HxButton).Assembly.GetTypes().FirstOrDefault((t) => t.FullName.Contains(typeName));
if (result is not null)
{
return result;
}
}
catch { }
}

return null;
}
}

0 comments on commit a17d2b8

Please sign in to comment.