From a17d2b88d6acada0e42ff364717956012ffb0ab0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mikul=C3=A1=C5=A1=20Hobl=C3=ADk?= Date: Fri, 10 Nov 2023 17:40:25 +0100 Subject: [PATCH] InternalTypeDoc - fallback - find type containing the specified type name --- .../Pages/InternalTypeDoc.razor.cs | 2 +- Havit.Blazor.Documentation/Services/ApiHelper.cs | 15 ++++++++++++++- 2 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Havit.Blazor.Documentation/Pages/InternalTypeDoc.razor.cs b/Havit.Blazor.Documentation/Pages/InternalTypeDoc.razor.cs index 18583937..4add7449 100644 --- a/Havit.Blazor.Documentation/Pages/InternalTypeDoc.razor.cs +++ b/Havit.Blazor.Documentation/Pages/InternalTypeDoc.razor.cs @@ -12,7 +12,7 @@ protected override void OnParametersSet() { try { - type = ApiTypeHelper.GetType(TypeText); + type = ApiTypeHelper.GetType(TypeText, true); } catch { diff --git a/Havit.Blazor.Documentation/Services/ApiHelper.cs b/Havit.Blazor.Documentation/Services/ApiHelper.cs index 7349d741..8b3d4b30 100644 --- a/Havit.Blazor.Documentation/Services/ApiHelper.cs +++ b/Havit.Blazor.Documentation/Services/ApiHelper.cs @@ -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; @@ -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; } }