Define a class
Public class mapserverproxy implements imapserverproxy {private VaR _ handler: function; // function-corresponding parameter method. Private VaR _ capabilities: imapservercapabilities; // real parameters of the parameter method. Public Function getcapabilities (): imapservercapabilities {return _ capabilities;} // you can specify a real parameter for the parameter method. Private function resulthandle (data: Object): void {var capabilities: imapservercapabilities = new mapserverrestcapabilities (data, _ request. URL); this. _ capabilities = capabilities; If (_ handler) _ handler (capabilities); // input a real parameter to the parameter method. ##### // Third, pass the real parameter to the method defined in step 1. The parameter types here must be consistent} // second, define a function object to store real parameters, assign a value to _ handler // main method, and the parameter type is a method. Public Function loadcapabilities (handler: function = NULL): void {// You can also input real parameters to the parameter method. This. _ handler = handler; // assign a value to the method variable: Assign the passed Method to the variable in the class .}}
Define a method as a parameter
// First, define a method M // define a method. The parameters of this method must be the same as the method type used to call this method. In the above example, ### mark the statement. Private function basemapserverloadedhandle (capabilities: imapservercapabilities): void {inittiledlayer (capabilities, true); // The parameter of this method has a specific value. Here, inittiledlaye is another method, which is not required .}
Define a class variable and call the methods in this class
// Fourth, pass M as an object to public var basemapserverproxy: imapserverproxy; basemapserverproxy. loadcapabilities (basemapserverloadedhandle) in method N; // use the method as a parameter. The real parameters in the parameter method are assigned values in the class.
--