RISE to Bloome Software
Log In    
Home
RISE
Marshal
Download
 
 
Site Map Site Map
Link to Us Link to Us
r2bsoftware.se r2bsoftware.se
 
 
RISE Version 4.5RISE Version 4.5
RISE Visual ModelingRISE Visual Modeling
AJAX Code GeneratorAJAX Code Generator
 
 
Bookmark and Share
 
Click to hide navigation tree
c# custom method
This sample is available for download as a Visual Studio project.
 
A c# custom method implementation needs to meet the following requirements in order for the generated code to be able to invoke it:
  1. The implementation file needs to include the namespace System.Data.Odbc.
  2. The implementation file needs to include the namespace of the automatically generated interface class. It's named <prefix>.DB.<interface name>.
  3. The implementation file must contain the namespace assigned to the RISE custom method.
  4. The implementation namespace must contain (implement) the class assigned to the RISE custom method.
  5. The implementation class must provide a constructor accepting an OdbcCommand unless the NoDatabase property has been set to True, in which case the default constructor is called instead, see samples below.
  6. The implementation class must implement methods having the same signature (name, arguments and output) as the corrresponding RISE custom method.
Suppose we create an interface, MyInterface, in a RISE model having prefix MyPrefix. MyInterface is then assigned a method, MyMethod, with a signature according to the picture below.
 
 
We also specify, in the RISE Editor, that the method should use the class MyClass in the namespace MyNamespace. Once all this is done we generate the interface. The generated code will now attempt to call an implementation corresponding to the below sample code.
 
using System.Data.Odbc;
using MyPrefix.DB.MyInterface; // Namespace of generated interface
namespace MyNamespace
{
  public class MyClass
  {
    private OdbcCommand _cmd = null;
    public MyClass(OdbcCommand cmd)
    { // cmd is connected and ready for calling the MyPrefix database
      _cmd = cmd;
    }
    public returnMyMethod MyMethod(int a)
    {
      returnMyMethod rv = new returnMyMethod();
      rv.b = "MyMethod got "+ a.ToString(); // Do whatever!
      return rv;
    }
  }
}
 
If the custom method is specified as not using the solution database the below, simplified, template is expected.
 
using MyPrefix.DB.MyInterface; // Namespace of generated interface
namespace MyNamespace
{
  public class MyClass
  {
    public MyClass()
   
    }
    public returnMyMethod MyMethod(int a)
    {
      returnMyMethod rv = new returnMyMethod();
      rv.b = "MyMethod got "+ a.ToString(); // Do whatever!
      return rv;
    }
  }
}
 
In a .NET web service you should either compile your web service application consisting of both the generated code and the custom code or you can place the custom code file directly in the App_Code sub-directory for dynamic loading.