File tree Expand file tree Collapse file tree
Components/BaseComponents Expand file tree Collapse file tree Original file line number Diff line number Diff line change 33// See the LICENSE file in the project root for more information.
44// Maintainer: Argo Zhang(argo@live.ca) Website: https://www.blazor.zone
55
6- using System . Reflection ;
7-
86namespace BootstrapBlazor . Components ;
97
108/// <summary>
@@ -82,13 +80,11 @@ protected override async Task OnAfterRenderAsync(bool firstRender)
8280 protected virtual void OnLoadJSModule ( )
8381 {
8482 var type = this . GetType ( ) ;
85- var inherited = type . GetCustomAttribute < JSModuleNotInheritedAttribute > ( ) == null ;
86- if ( inherited )
83+ if ( CacheManager . GetAttribute < JSModuleNotInheritedAttribute > ( type ) == null )
8784 {
88- var attributes = type . GetCustomAttributes < JSModuleAutoLoaderAttribute > ( ) ;
89- if ( attributes . Any ( ) )
85+ var attr = CacheManager . GetAttribute < JSModuleAutoLoaderAttribute > ( type ) ;
86+ if ( attr != null )
9087 {
91- var attr = attributes . First ( ) ;
9288 AutoInvokeDispose = attr . AutoInvokeDispose ;
9389 AutoInvokeInit = attr . AutoInvokeInit ;
9490
Original file line number Diff line number Diff line change @@ -216,6 +216,22 @@ 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+
219235 #region Assembly
220236 /// <summary>
221237 /// 获得唯一类型名称方法
You can’t perform that action at this time.
0 commit comments