File tree Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Expand file tree Collapse file tree 2 files changed +21
-3
lines changed Original file line number Diff line number Diff line change @@ -14,7 +14,5 @@ static class AssemblyExtensions
1414 /// </summary>
1515 /// <param name="assembly"></param>
1616 /// <returns></returns>
17- public static string GetUniqueName ( this Assembly assembly ) => assembly . IsCollectible
18- ? $ "{ assembly . GetName ( ) . Name } -{ assembly . GetHashCode ( ) } "
19- : $ "{ assembly . GetName ( ) . Name } ";
17+ public static string GetUniqueName ( this Assembly assembly ) => CacheManager . GetUniqueName ( assembly ) ;
2018}
Original file line number Diff line number Diff line change @@ -216,6 +216,26 @@ private List<ICacheEntry> GetAllValues(MemoryCache cache)
216216 }
217217#endif
218218
219+ #region Assembly
220+ /// <summary>
221+ /// 获得唯一类型名称方法
222+ /// </summary>
223+ /// <param name="assembly"></param>
224+ /// <returns></returns>
225+ public static string GetUniqueName ( Assembly assembly )
226+ {
227+ //key不拼接,作为当前静态实例唯一标识,因为GetUniqueName方法会被频繁调用
228+ return Instance . GetOrCreate ( assembly , _ =>
229+ {
230+ return assembly . IsCollectible
231+ ? $ "{ assembly . GetName ( ) . Name } -{ assembly . GetHashCode ( ) } "
232+ : $ "{ assembly . GetName ( ) . Name } ";
233+ }
234+ ) ;
235+ }
236+
237+ #endregion
238+
219239 #region Count
220240 public static int ElementCount ( object ? value )
221241 {
You can’t perform that action at this time.
0 commit comments