Skip to content

Commit 2a6f379

Browse files
committed
refactor: 撤销 GetAttribute 缓存
1 parent 18bc459 commit 2a6f379

2 files changed

Lines changed: 5 additions & 19 deletions

File tree

src/BootstrapBlazor/Components/BaseComponents/BootstrapModuleComponentBase.cs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -80,11 +80,13 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
8080
protected virtual void OnLoadJSModule()
8181
{
8282
var type = this.GetType();
83-
if (CacheManager.GetAttribute<JSModuleNotInheritedAttribute>(type) == null)
83+
var inherited = type.GetCustomAttribute<JSModuleNotInheritedAttribute>() == null;
84+
if (inherited)
8485
{
85-
var attr = CacheManager.GetAttribute<JSModuleAutoLoaderAttribute>(type);
86-
if (attr != null)
86+
var attributes = type.GetCustomAttributes<JSModuleAutoLoaderAttribute>();
87+
if (attributes.Any())
8788
{
89+
var attr = attributes.First();
8890
AutoInvokeDispose = attr.AutoInvokeDispose;
8991
AutoInvokeInit = attr.AutoInvokeInit;
9092

src/BootstrapBlazor/Services/CacheManager.cs

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -216,22 +216,6 @@ private List<ICacheEntry> GetAllValues(MemoryCache cache)
216216
}
217217
#endif
218218

219-
#region Attribute
220-
/// <summary>
221-
/// 获得类型特性标签方法
222-
/// </summary>
223-
/// <param name="type"></param>
224-
/// <returns></returns>
225-
public static Attr? GetAttribute<Attr>(Type type) where Attr : Attribute
226-
{
227-
return Instance.GetOrCreate((type, typeof(Attr)), _ =>
228-
{
229-
return type.GetCustomAttribute<Attr>();
230-
});
231-
}
232-
233-
#endregion
234-
235219
#region Assembly
236220
/// <summary>
237221
/// 获得唯一类型名称方法

0 commit comments

Comments
 (0)