Cora Knowledge Center

Support

Extend Expressions using the API

To extend expressions functionality using the API, you must write a .NET class. For example, the class below enables access to the AppSettings section in the configuration file.

using System.Configuration;
 
namespace SequenceEx.ExpressionExtensions
{
 public class ConfigurationManagerExpressionExtension
 {
 private static ConfigurationManagerExpressionExtension instance = new ConfigurationManagerExpressionExtension();
 //Used by the expression language to access type members (not required)...
 public static ConfigurationManagerExpressionExtension Instance
 {
 get
 {
 return instance;
 }
 }
 
 public string GetAppSetting(string key)
 {
 return ConfigurationManager.AppSettings[key];
 }
 }
}

Next, register the class in the application's configuration file.

<sectionGroup name="sequence.engine" type="PNMsoft.Sequence.Configuration.WorkflowEngineConfigurationSectionGroup, PNMsoft.Sequence, Version=7.0.0.0, Culture=neutral, PublicKeyToken=0a1a1b90c1c5dca1">
 ….
 <section name="expressions" type="PNMsoft.Sequence.Configuration.ExpressionsConfigurationSection, PNMsoft.Sequence, Version=7.0.0.0, Culture=neutral, PublicKeyToken=0a1a1b90c1c5dca1"/>
 
 
 <sequence.engine>
 ….
 <expressions>
 <extensions>
 <add name="config" type="SequenceEx.ExpressionExtensions.ConfigurationManagerExpressionExtension, SequenceEx.ExpressionExtensions, Version=1.0.0.0, Culture=neutral, PublicKeyToken=3b0897bc897d702d" />
 </extensions>
 </expressions>

You can now use an expression, such as #config.GetAppSetting(YourAppSettingsKey)