// Load all extensions in the given directory and fire the Init command off public static void Load(string dir) { // Prevent this command from being executed if Loaded isn't null if (Loaded != null) { return; } // Set dir ExtensionsDir = dir; // Get all assemblies Assembly[] assemblies = GetAssemblies(dir); // Get all types Type[] types = GetTypes(assemblies); // Create a dictionary for the loaded extensions Dictionary <string, IExtension> extensions = new Dictionary <string, IExtension> (types.Length); // Create an instance of the extensions and run the Init commands foreach (Type type in types) { IExtension ext = (IExtension)Activator.CreateInstance(type); ext.Init(); extensions.Add(ext.Name(), ext); } // Commit the extensions list to the loaded array Loaded = extensions; }