Closed
Description
Hi! I have to get all implementations (classes) of some interface. How I can do that? Now I only can to make it for current assembly (project), but the goal is to have it in separate project:
public T GetRepository()
{
foreach (Type type in typeof(T).GetTypeInfo().Assembly.GetTypes())
if (typeof(T).IsAssignableFrom(type) && type.GetTypeInfo().IsClass)
return (T)Activator.CreateInstance(type);
return default(T);
}