C# Helper util to easily find types by their name, interface or annotated attribute.
// class declaration
public class ChocolateFabric : IChocolateFabric {
...
}
// HappyReflection code
IList<Type> aListContainingChocolateFabric = HappyReflection.GetClassesByInterface<IChocolateFabric>();
// result
new List<Type> { typeof(ChocolateFabric) }
// class declaration
public class ChocolateFabric {
...
}
// HappyReflection code
Type typeOfChocolateFabric = HappyReflection.GetTypeByName("ChocolateFabric");
// result
typeof(ChocolateFabric)
// class declaration
[ILoveChocolateAttribute]
public class ChocolateFabric {
...
}
// HappyReflection code
IList<Type> typeOfChocolateFabric = HappyReflection.GetClassesByAttribute<ILoveChocolateAttribute>();
// result
new List<Type> { typeof(ChocolateFabric) }