In the previous article, the plug-in interface IModule of AgileEAS. NET introduced the basic contract meaning of the plug-in, that is, the interface. This article will provide the definition of another module plug-in, using the property tag plug-in.
We have defined the ModuleAttribute attribute:
ModuleAttribute // <summary> // attributes of the EAS. NET module plug-in. /// </Summary> /// <remarks> // provides the IModule tag implementation and the attribute tag-based plug-in implementation. /// </Remarks> [AttributeUsage (AttributeTargets. class)] public class ModuleAttribute: Attribute {private Guid guid = System. guid. empty; private string name = string. empty; private string description = string. empty; // <summary> // initialize the ModuleAttribute object. /// </Summary> /// <param name = "guid"> module Guid. </Param> /// <param name = "name"> Module name. </Param> public ModuleAttribute (string guid, string name) {this. guid = new Guid (guid); this. name = name ;}/// <summary> // initialize the ModuleAttribute object. /// </Summary> /// <param name = "guid"> module Guid. </Param> /// <param name = "name"> Module name. </Param> /// <param name = "description"> module description. </Param> public ModuleAttribute (string guid, string name, string description) {this. guid = new Guid (guid); this. name = name; this. description = description;} // <summary> // module Guid. /// </Summary> public string Guid {get {return this. guid. toString ();} set {this. guid = new Guid (value) ;}/// <summary> /// Module name. /// </Summary> public string Name {get {return this. name;} set {this. name = value ;}//< summary> /// module description. /// </Summary> public string Description {get {return this. description;} set {this. description = value ;}}
And ModuleRunAttribute attributes
ModuleRunAttribute /// <summary> // module entry method attribute. /// </Summary> /// <remarks> /// use ModuleAttribute to implement the Mark-based IMoule module. /// </Remarks> [AttributeUsage (AttributeTargets. Method)] public class ModuleRunAttribute: Attribute {// <summary> // initialize the ModuleRunAttribute object. /// </Summary> public ModuleRunAttribute (){}}
We only need to mark ModuleAttributes on the class of the module plug-in we want to public, and add ModuleRunAttribute on the module's entry call method. The following is an example:
Hello /// <summary> /// plug-in implemented based on tags. /// </Summary> [Module ("CB58C5BB-5D15-4a17-802E-341F9F65F35C", "Hello example", "tag-based Module implementation example")] public class Hello {// <summary> // entry method. /// </Summary> [ModuleRun] public void Start () {MessageBox. show ("Hello... ");} public void Start2 () {MessageBox. show ("Hello2... ");}}
In the above example, we marked a module plug-in, whose GUID attribute is "CB58C5BB-5D15-4a17-802E-341F9F65F35C", the module name is Hello example, the entry method is the Start method, specifically declare, start must be a public parameter, and the Web module does not need the entry method.
Link: AgileEAS. NET application development platform Introduction
Agile parallel development method of AgileEAS. NET
Agile Software Engineering Lab