diff --git a/MBS.Framework/Reflection.cs b/MBS.Framework/Reflection.cs index 163ec7e..315cfaa 100644 --- a/MBS.Framework/Reflection.cs +++ b/MBS.Framework/Reflection.cs @@ -98,16 +98,28 @@ namespace MBS.Framework private static Assembly[] mvarAvailableAssemblies = null; - public static Assembly[] GetAvailableAssemblies() + /// + /// Gets the available assemblies in the given search paths, or the current application directory if no search paths are specified. + /// + /// The available assemblies. + /// An array of paths to search in. + public static Assembly[] GetAvailableAssemblies(string[] searchPaths = null) { if (mvarAvailableAssemblies == null) { List list = new List(); List asmdirs = new List(); - string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); + string dir = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetCallingAssembly().Location); asmdirs.Add(dir); asmdirs.Add(dir + System.IO.Path.DirectorySeparatorChar.ToString() + "Plugins"); + if (searchPaths != null) + { + for (int i = 0; i < searchPaths.Length; i++) + { + asmdirs.Add(searchPaths[i]); + } + } foreach (string asmdir in asmdirs) { @@ -221,10 +233,15 @@ namespace MBS.Framework } } - public static ManifestResourceStream[] GetAvailableManifestResourceStreams() + /// + /// Gets the available manifest resource streams in the given search paths, or the current application directory if no search paths are specified. + /// + /// The available manifest resource streams. + /// An array of paths to search in. + public static ManifestResourceStream[] GetAvailableManifestResourceStreams(string[] searchPaths = null) { List list = new List(); - Assembly[] asms = MBS.Framework.Reflection.GetAvailableAssemblies(); + Assembly[] asms = MBS.Framework.Reflection.GetAvailableAssemblies(searchPaths); for (int i = 0; i < asms.Length; i++) { string[] resnames = asms[i].GetManifestResourceNames();