feat: init avalonia demo.
This commit is contained in:
1 parent
adb6355884
commit
63bf5c6aa7
95 files changed
+20896
-2634
No files matched your search
@@ -0,0 +1,36 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace HandyControlDemo.Tools;
|
||||
|
||||
internal class AssemblyHelper
|
||||
{
|
||||
private static readonly string NameSpaceStr = typeof(AssemblyHelper).Assembly.GetName().Name!;
|
||||
|
||||
private static readonly Dictionary<string, object> CacheDic = [];
|
||||
|
||||
public static void Register(string name, object instance) => CacheDic[name] = instance;
|
||||
|
||||
public static object? ResolveByKey(string key)
|
||||
{
|
||||
if (CacheDic.TryGetValue(key, out var value))
|
||||
{
|
||||
return value;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
public static object? CreateInternalInstance(string className)
|
||||
{
|
||||
try
|
||||
{
|
||||
var type = Type.GetType($"{NameSpaceStr}.{className}");
|
||||
return type == null ? null : Activator.CreateInstance(type);
|
||||
}
|
||||
catch
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user