There are two ways you can go ahead and do it programmatically.
-
The first way is just to mimic the manual operation you did by adding External Function in the Console. You do that by adding one or more records of the IMethodBasedFunctionInfo data-type (https://github.com/Orckestra/C1-CMS/blob/master/Composite/Data/Types/IMethodBasedFunctionInfo.cs).
-
The second way, which is also the best when it comes to maintainability and extensibility, is to write a Function Provider. There is a wide range of different providers in C1 already which you can see here https://github.com/Orckestra/C1-CMS/tree/master/Composite/Plugins/Functions/FunctionProviders, and its not that hard to add new ones. Ps. Function Providers needs to be registered in composite.config before they show up in the console (https://github.com/Orckestra/C1-CMS/blob/master/Website/App_Data/Composite/Composite.config#L376)