IMenuProvider Interface

Assembly: CodeEffects.Rule.Editor.dll
Namespace: CodeEffects.Rule.Editor.Models

Syntax

using CodeEffects.Rule.Editor.Client;

namespace CodeEffects.Rule.Editor.Models
{
	public interface IMenuProvider
	{
		string SourceObjectTypeOrAliasName { get; }

		IMenu GetSettersAndActions(Context context);
		IMenu GetFieldsAndMethods(Context context);

		Field GetField(string fieldName);
		Field GetSetter(string fieldName);
		Field GetReusableRule(string ruleID);

		Function GetMethod(string methodName);
		Function GetAction(string methodName);

		Enum GetEnum(string enumName);
		DataSource GetDataSource(string dataSourceName);
	}
}

Summary

Provides the server-side contract used by Adaptive Source to supply fields, methods, setters, actions, reusable rules, enumerations, and dynamic menu data sources to the Rule Editor on demand.

Properties

  • SourceObjectTypeOrAliasName

    Type: System.String

    Gets the assembly-qualified type name or alias name of the source object used by the rules. Required.

Methods

  • GetAction

    Returns: CodeEffects.Rule.Editor.Client.Function

    Returns metadata for a rule action referenced by a rule. The editor calls this method when it needs to resolve an action method used by an execution type rule.

    Parameters

    • methodName (System.String) - "Combined" name of the method (see Remarks below for definition.) This value must match the Function.Value assigned to the method metadata.
  • GetEnum

    Returns: CodeEffects.Rule.Editor.Client.Enum

    Returns metadata for an enumeration used by a field, method parameter, or method return value. Adaptive Source does not require the editor to reflect enum types at design time. Your menu provider supplies the enum metadata when the editor requests it.

    Parameters

    • enumName (System.String) - "Combined" name of the enum (see Remarks below for definition.) This value must match the Enum.Name assigned to the enum metadata.
  • GetDataSource

    Returns: CodeEffects.Rule.Editor.Client.DataSource

    Returns metadata for a dynamic menu data source. These data sources can be loaded from any source available to your application, including databases, APIs, configuration files, or cached metadata.

    Parameters

    • dataSourceName (System.String) - "Combined" name of the data source (see Remarks below for definition.) This value must match the DataSource.Name assigned to the data source metadata.
  • GetField

    Returns: CodeEffects.Rule.Editor.Client.Field

    Returns metadata for a field referenced by a rule. The editor calls this method when it needs to resolve a field by name, usually while loading or updating existing RuleXML.

    Parameters

    • fieldName (System.String) - "Combined" name of the field (see Remarks below for definition.) This value must match the Field.Value assigned to the method metadata.
  • GetFieldsAndMethods

    Returns: CodeEffects.Rule.Editor.Models.IMenu

    Returns fields and in-rule methods that should be available in the next condition menu.

    Parameters

  • GetMethod

    Returns: CodeEffects.Rule.Editor.Client.Function

    Returns metadata for an in-rule method referenced by a rule. The editor calls this method when it needs to resolve an in-rule method by name.

    Parameters

    • methodName (System.String) - "Combined" name of the method (see Remarks below for definition.) This value must match the Function.Value assigned to the method metadata.
  • GetReusableRule

    Returns: CodeEffects.Rule.Editor.Client.Field

    Returns metadata for a reusable rule. Reusable rules are exposed to the editor as Boolean fields. The ruleID parameter identifies the reusable evaluation type rule that should be loaded into the menu or resolved from RuleXML.

    Parameters

    • ruleID (System.String) - String value of the rule's GUID ID.
  • GetSettersAndActions

    Returns: CodeEffects.Rule.Editor.Models.IMenu

    Returns setters and rule actions that should be available in the next action menu.

    Parameters

  • GetSetter

    Returns: CodeEffects.Rule.Editor.Client.Field

    Returns metadata for a settable field referenced by a rule. The editor calls this method when it needs to resolve a field used as a value setter. The returned field should represent a field that can be assigned a value by an execution type rule.

    Parameters

    • fieldName (System.String) - "Combined" name of the setter (see Remarks below for definition.) This value must match the Field.Value assigned to the method metadata.

Remarks

IMenuProvider is the main implementation point of Adaptive Source. To use Adaptive Source, create a class that implements this interface and assign its instance to the Control.MenuProvider property:

var editor = new Control("divEditor");
editor.MenuProvider = new MenuProvider(typeof(YourSourceObject));

Setting the MenuProvider property tells the editor to use the Adaptive Source model. From that point on, the editor uses your provider to request rule metadata as the rule author creates, loads, or updates rules.

The provider has two main responsibilities:

  • Generate dynamic menus based on the current rule context.
  • Resolve existing rule elements referenced by RuleXML.

This allows the editor to work without loading the entire source object into the browser.

IMPORTANT! The Value properties of fields and methods, as well as the Name property of enums and data sources supplied by an Adaptive Source menu provider use combined names. A combined name must be in dot notation and consist of the source object's class name (or its alias name) followed by the declared name of the member.

The menu provider included in our demo projects automatically generates combined names. It provides a production-ready implementation of the IMenuProvider interface that you can use as a starting point or copy directly into your own projects.

Combined Name Example

// Source object
public class MySource
{
	public string UserID { get; set; } = 0;
}

// Meta description of the UserID property
var field = new Field { Value = "MySource.UserID", DisplayName = "User ID", Min = 0 };

p102

l097 --

l102

p101

×