C# Functions

Adding External C# Functions in CMS Console

To add one of the C# methods (created externally) as an external C# function in C1 CMS:

  1. In Functions, select C# Functions and click Add External C# Function.
  2. In Step 1 of the wizard, in the Type field specify the class the method belongs to (including namespaces) (e.g. “Demo.Functions”).

    Figure 14: Step 1: Specifying the C# method’s type

  3. In Step 2, select the Method name from the list (e.g. “CurrentDate”).

    Figure 15: Step 2: Selecting the C# method by name

  4. In Step 3, if necessary, change the Method Name and Namespace Name suggested by C1 CMS for the external C# function.

    Figure 16: Step 3: Specifying the name and the namespace for the external C# function

  5. Click Finish.

The external C# function will appear under C# Functions in the Functions perspective.

Please note that values in Step 1 and 2 of the wizard (Type, Method name) are taken from the C# method you have created in your code editor and must be exact. The values in Step 3 of the wizard (Method Name, Namespace Name) make up the name of the external C# function in C1 CMS and can be arbitrary.

If you edit such a function in C1 CMS in the Functions perspective, you will be able to change the following settings:

  • Method Name: The name of the external C# function (in C1 CMS)
  • Namespace Name: The name of the namespace the external C# function belongs to (in C1 CMS)
  • Type: The actual name of the namespace(s) and the class the C# method belongs to (in external code editor)
  • Method: The actual name of the C# method (in external code editor)

Figure 17: Editing an external C# function’s properties

To edit the code behind this function, you should open the corresponding C# file (.cs) in your code editor and edit the corresponding C# method therein.