标签:ESS tin new catch sel app tty sem throw
var assemblies = new List<Assembly>() { typeof(OEAppHost).Assembly };
var types = assemblies.SelectMany(x => x.GetTypes())
.Where(x => (x.GetInterfaces().Contains(typeof(ICheckOrder))))
.ToArray();
var checkOrderInstances = types.Select(x => x.CreateInstance()).ToList();
void RunNeedCheckProcess(object instance)
{
try
{
if (instance is ICheckOrder checkOrder)
checkOrder.Execute();
}
catch (Exception)
{
}
}
checkOrderInstances.ForEach(RunNeedCheckProcess);
static class ReflectExtension
{
public static bool HasInterface(this Type type, Type interfaceType)
{
foreach (var t in type.GetInterfaces())
{
if (t == interfaceType)
return true;
}
return false;
}
}
public interface ICheckOrder
{
void Execute();
}
public class CheckOrderName : ICheckOrder
{
public void Execute()
{
//throw new NotImplementedException();
}
}
标签:ESS tin new catch sel app tty sem throw
原文地址:https://www.cnblogs.com/wt-li/p/11889805.html