Search

 

Module: Editor

Version: 17.01 +

 

Description

Futurama comes with an extensive Formula Library. In some cases you might want to add formulas to the library. At this support page is explained how to add custom formulas to this library. To use these custom formulas a Futurama PlugIn has to be defined. See the Configuration – PlugIns section how to do this configuration.

Developing an external formula library

To add your own formulas you need to develop a .Net DLL. With this DLL you can add an entire library of custom formulas. This DLL should implement the interface IExternalFormulaLibrary, as defined in the DLL ActuIT.Futurama.IoCInterfaces.dll that is part of Futurama. In this library there are only two methods:

GetLibraryName

This method should return a string with the name of the library.

GetFormulasDocument

The method GetFormulasDocument should return an XML Document containing an XML definition of the formulas defined in the library.

Custom methods

Apart from the two mandatory methods you can add your own methods with formulas you want to make available to Futurama.

Requirements for methods

The methods should meet the next requirements:

  • method should be static
  • method should be public
  • the input types can be any of the following
    • int
    • double
    • string
    • bool
    • DateTime
  • the return value should be one of the following
    • int
    • double
    • string
    • bool
    • DateTime

Sample code

namespace SampleFormulaPlugin
{
    public class CustomFormulas : ActuIT.Futurama.IoCInterfaces.IExternalFormulaLibrary
    {
        
        public XDocument GetFormulasDocument()
        {
            Stream formulaxml = Assembly.GetExecutingAssembly().GetManifestResourceStream("SampleFormulaPlugin.CustomFormulas.xml");
            return System.Xml.Linq.XDocument.Load(formulaxml);
        }
        public string GetLibraryName()
        {
            return "Various custom formulas";
        }

        public static int SampleCustomFormula(int input)
        {
            return input * 17 + 5;
        }
    }
}

Xml document with Formula definition

Here is sample XML document with formulas.

<!--?xml version="1.0" encoding="utf-8"?-->
<formulalibrary version="4.1.2">
	<!-- the language information in a plugin is not used -->
	<languages>
		<language id="NL" name="">
		</language>
	</languages>
	<categories>
		<category id="1" order="1">
			<language id="">
				<name>SamplePlugin:Custom</name>
			</language>
		</category>
	</categories>
	<!-- you can define multiple formulas-->
	<formulas>
		<!-- the id's should start with 1
    method should be the method name as defined in the class
    class is the name of the class in the plugin
    type is the return type. The allowed types are System.Int32, System.Double, System.String, System.Boolean, System.DateTime 
    -->
		<formula id="1" method="SampleCustomFormula" class="SampleFormulaPlugin.CustomFormulas" type="System.Int32" categoryid="1">
			<language id="">
				<!-- the name of the formula that as it appears in the editor-->
				<name>SampleCustomFormula</name>
				<!-- the description of the formula as it appears in the editor-->
				<description>Determines the value of some business rule</description>
			</language>
			<parameter type="System.Int32" position="1" isarray="false">
				<language id="">
					<!-- the name of the parameter that is shown in the editor-->
					<name>Input</name>
					<!-- the description of the parameter that is shown in the editor-->
					<description>The input for the business rule</description>
				</language>
			</parameter>
		</formula>
		<!-- you can also add formulas that are defined in the .Net classes by Microsoft -->
		<formula id="2" method="Sin" class="System.Math" type="System.Double" categoryid="1">
			<language id="">
				<name>Sinus</name>
				<description>Determines the sinus for an angle</description>
			</language>
			<parameter type="System.Double" position="1" isarray="false">
				<language id="">
					<name>Angle</name>
					<description>The angle in radians for which you want to calculate the sinus</description>
				</language>
			</parameter>
		</formula>
	</formulas>
</formulalibrary>

Related Topics

- Plugins: Settings to define Futurama plugins

Feedback

If you have any questions about this subject or if you want to provide us feedback please send us an e-mail.

Updated: 2016-12-21