Example Analysis based on XML Module Integration Framework
0) {GetChildMenu (ip,childitem, child1) } / * * / Open a combination of form / form class assembly and form class, and get private void OpenForm (MenuClass mc) {string asmname = mc.Assemblyname; string formtag = mc.FormTag from the AssemblyName property of the node. If (formtag = = "") {throw new Exception (Resources.StringNoFormFlag);} if (formtag.ToUpper () = = "TRUE") {if (asmname = = string.Empty) {throw new NullReferenceException (Resources.StringAssemblyNull) } / / string [] a = asmname.Split (','); object obj = null; Type tp = Type.GetType (asmname); if (tp! = null) {obj = Activator.CreateInstance (tp) } else {throw new Exception ("an error occurred while loading the program, please check whether the program (dll,exe) exists or is of the correct type.") ;} / / check whether it is Form class if ((obj = = null) |! (obj is Form)) {throw new Exception (Resources.StringNotForm);} Form frm = (obj as Form) / / check whether the first window opened is MDIFORM if (Application.OpenForms [0] .IsMdiContainer) {/ / as MDICHILDFORM frm.MdiParent = Application.OpenForms [0];} / load form frm.Show () }} / * / menu Click event / private void OnPluginClick (object sender, EventArgs args) {OfficeMenuItem item = (OfficeMenuItem) sender; MenuClass mc = (MenuClass) item.Tag If ((item.Text = = "EXIT") | (item.Text = = "EXIT") {OnExitClick (sender, args); return;} OpenForm (mc);}}
Delegate is used in this, and the most important function is to load the menu function and the OnPluginClick function.
Using this framework, you can dynamically add modules at any level.
Microsoft's CAB uses Resigster site to add modules, which is not very convenient.
This is the end of this article on "sample Analysis based on XML Module Integration Framework". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.