private ListvisualPlugs = new List (); public void Load() { DirectoryInfo di = new DirectoryInfo(AppDomain.CurrentDomain.BaseDirectory); foreach (FileInfo fi in di.GetFiles("VisualControls.*.dll")) { Assembly lib = Assembly.LoadFrom(fi.FullName); foreach (Type t in lib.GetExportedTypes()) { if (t.GetInterface(typeof(IVisualControlsPlug).FullName) != null) { IVisualControlsPlug plug = (IVisualControlsPlug)Activator.CreateInstance(t); InitializePlugin(Env.Current, plug); } } } } private void InitializePlugin(IEnvironment env, IVisualControlsPlug plug) { plug.Initialize(env); visualPlugs.Add(plug); }//重载操作符 public IVisualControlsPlug this[string pluginId] { get { foreach (IVisualControlsPlug plug in visualPlugs) if (plug.PluginId == pluginId) return plug; return null; } }