private List <TInterfaceToFind> GetAllEndpointOptions <TInterfaceToFind>() where TInterfaceToFind : IEndpointOptions { List <Type> types = AppDomain.CurrentDomain.GetAssemblies() .Where(a => !a.IsDynamic) .SelectMany(a => a.GetTypes()) .Where(t => t.IsAssignableFrom(typeof(TInterfaceToFind))).ToList(); List <TInterfaceToFind> output = new List <TInterfaceToFind>(); foreach (Type type in types) { TInterfaceToFind option = (TInterfaceToFind)Activator.CreateInstance(type); option.SetDefaults(); output.Add(option); } return(output); }
private List <TInterfaceToFind> GetAllTypes <TInterfaceToFind>() where TInterfaceToFind : IOptions { AppDomain.CurrentDomain.Load("MigrationTools"); AppDomain.CurrentDomain.Load("MigrationTools.Clients.AzureDevops.ObjectModel"); AppDomain.CurrentDomain.Load("MigrationTools.Clients.FileSystem"); List <Type> types = AppDomain.CurrentDomain.GetAssemblies() .Where(a => a.FullName.StartsWith("MigrationTools")) .SelectMany(a => a.GetTypes()) .Where(t => typeof(TInterfaceToFind).IsAssignableFrom(t) && !t.IsInterface && !t.IsAbstract && t.Name != "Object").ToList(); List <TInterfaceToFind> output = new List <TInterfaceToFind>(); foreach (Type type in types) { TInterfaceToFind option = (TInterfaceToFind)Activator.CreateInstance(type); option.SetDefaults(); output.Add(option); } return(output); }