using System;
|
|
using System.Collections.Generic;
|
|
using Forks.Utils;
|
|
|
|
namespace BO {
|
|
[AttributeUsage(AttributeTargets.Class)]
|
|
public sealed class BOClassAttribute : Attribute {
|
|
public bool Exclude { get; set; }
|
|
|
|
public static bool IsBo(Type t) {
|
|
var attr = ReflectionUtil.GetAttribute<BOClassAttribute>(t);
|
|
if (attr == null) {
|
|
return false;
|
|
}
|
|
return !attr.Exclude;
|
|
}
|
|
|
|
public static IEnumerable<Type> GetBoClasses() {
|
|
var asm = typeof(BOClassAttribute).Assembly;
|
|
foreach (var t in asm.GetExportedTypes()) {
|
|
if (t.IsAbstract) {
|
|
continue;
|
|
}
|
|
if (t.IsClass && IsBo(t)) {
|
|
yield return t;
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|