/// <summary> /// Gets the instances from any given assembly path with specific filter /// </summary> /// <typeparam name="T">Generic - any interface</typeparam> /// <param name="assemblyPath">assemblies folder location</param> /// <param name="filter">file filter</param> /// <returns>List of Ts</returns> public static IList <T> GetInstancesFromAssemblyPath <T>(string assemblyPath, string filter) { IList <T> instances = new List <T>(); foreach (string filename in Directory.GetFiles(assemblyPath, filter)) { IList <object> registeredInstances = AssemblyResolver.Resolve(filename); IList <T> instancesT = Register <T>(registeredInstances); foreach (T obj in instancesT) { if (obj != null && instances.FirstOrDefault(IA => string.Compare(IA.GetType().FullName, obj.GetType().FullName, StringComparison.InvariantCultureIgnoreCase) == 0) == null) { instances.Add((T)obj); } } } return(instances); }
/// <summary> /// Gets the instances from the executing assembly /// </summary> /// <typeparam name="T">Generic - any interface</typeparam> /// <returns>List of Ts</returns> public static IList <T> GetInstancesFromExecutingAssembly <T>() { IList <object> registeredInstances = AssemblyResolver.Resolve(); return(Register <T>(registeredInstances)); }
/// <summary> /// Gets the instances from any given assembly file /// </summary> /// <typeparam name="T">Generic - any interface</typeparam> /// <param name="assemblyName">assembly file</param> /// <returns>List of Ts</returns> public static IList <T> GetInstancesFromAssembly <T>(string assemblyName) { IList <object> registeredInstances = AssemblyResolver.Resolve(assemblyName); return(Register <T>(registeredInstances)); }