/// <summary> /// Initializes the add-in tools. /// </summary> public void InitializeTools() { // This list is used to collect all the Add-In controls that are defined in the configuration file. Once the Add-Ins // have been instantiated, they will be added to the application frame as a range of controls. ArrayList toolStripItemList = new ArrayList(); // Load any dynamic tools into the application. ToolSection toolSection = (ToolSection)ConfigurationManager.GetSection("tools"); if (toolSection != null) { // This loop will load each add-in module and associate it with an object type code. foreach (ToolInfo toolInfo in toolSection) { ToolStripItem toolStripItem = new ToolStripMenuItem(); toolStripItem.Text = toolInfo.Text; toolStripItem.Size = new System.Drawing.Size(170, 22); toolStripItem.Click += new EventHandler(ToolHandler); toolStripItemList.Add(toolStripItem); } } // Copy the menu items into the 'Tools' menu. ToolStripItem[] toolStripItems = new ToolStripItem[toolStripItemList.Count]; toolStripItemList.CopyTo(toolStripItems, 0); this.toolsToolStripMenuItem.DropDownItems.AddRange(toolStripItems); }
private void toolStripButtonUserPreferences_Click(object sender, EventArgs e) { // Find the selected tool based on the text of the tool bar item and invoke the 'Show' method. For example, a tool // that dynamically handled the options would display the Options Dialog at this point. ToolSection toolSection = (ToolSection)ConfigurationManager.GetSection("tools"); foreach (ToolInfo toolInfo in toolSection) { if (toolInfo.Text == "&Options...") { object tool = toolInfo.ToolType.Assembly.CreateInstance(toolInfo.ToolType.ToString()); MethodInfo methodInfo = toolInfo.ToolType.GetMethod("Show", new Type[] { typeof(System.Windows.Forms.IWin32Window) }); methodInfo.Invoke(tool, new object[] { this }); } } }
List <Assembly> LoadAssemblies(ToolSection section, string path) { var assemblies = new List <Assembly>(); foreach (var node in section.TryGetNodes(path)) { var assemblyName = node.Attributes.TryGetValue("name"); try { var assembly = Assembly.Load(assemblyName); assemblies.Add(assembly); } catch (FileNotFoundException ex) { //忽略无法加载的程序集 } catch (Exception ex) { throw new PlatformException("无法加载程序集 " + assemblyName, ex); } } return(assemblies); }
public ShardConfiguration(ToolSection section) { this.section = section; }
public InterceptorConfiguation(ToolSection section) { this.section = section; interceptors.Add(new DefaultRepositoryFrameworkInterceptor()); }