Files
HandyControl/src/Shared/HandyControlDemo_Shared/Tools/Helper/AssemblyHelper.cs
T
NaBian 3aa0f09d39 improved notifyicon
added mouseenter and mouseleave events
2019-04-20 23:36:44 +08:00

38 lines
1015 B
C#

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 = new Dictionary<string, object>();
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;
}
}
}
}