Decision Automation with Code Effects
Introduction
Code Effects is a decision-automation platform for .NET that allows organizations to model, author, and execute complex business logic through clear, human-readable rules.
It consists of two tightly integrated components:
- The Rule Editor — a web-based, menu-driven interface for authoring and validating rules without writing code.
- The Rule Engine — a high-performance .NET library that loads, evaluates, and executes those rules at runtime.
Together, they provide a unified and transparent environment for defining, maintaining, and applying decision logic across modern .NET applications.
Concept Overview
A business rule is a declarative statement describing conditions and outcomes, such as:
If Age is greater than 18 and Active is equal to True then Begin Approval Process Else Decline ( Notification Type: Email )
Each rule is stored as a Rule XML document and can serve two closely related purposes:
- Evaluation: to make a decision and return a boolean result (
true or false).
- Data Filtering: to select data that meets the same conditions when applied to collections or database queries.
The second use - data filtering - is a side feature of the main decision-automation process. It exists because every business rule used for evaluation can also act as a conditional filter. Conceptually, the transition is simple:
if a rule begins with "Check if First Name is equal to John", you can easily imagine the same rule starting with "Get records where First Name is equal to John" — and it instantly becomes a data filter. For obvious reasons, the Data Filtering feature works only with evaluation-type rules (more about rule types later in this article).
Platform Architecture
The Code Effects platform is structured into three core layers:
Rule Authoring (Rule Editor)
The Rule Editor runs in the browser and constructs rules dynamically based on your data model called source object. Menus, operators, and value selectors are automatically generated from it.
Key features:
Dynamic menus show only valid fields and operations for each context.
Automatic validation highlights missing rule elements or logical inconsistencies before committing.
Parentheses grouping allows complex logic to be divided into hierarchical sections.
Example:
Check if ( Age is greater than 60 and Has Retirement Account is equal to True ) or ( State is equal to Georgia and Preferred equals to True )
Full Source Customization enables developers to control every meaningful aspect of each public member of the source object through custom attributes, including customization of the object’s own evaluation behavior.
Native Enumeration support allows direct use of .NET enumerations as context menus in rule conditions and actions, automatically displaying all defined values without additional configuration.
Dynamic Menu Data Sources feature enables the use of key-value pairs from databases, APIs, or other storage systems as context menus in rules, functioning just like native .NET enumerations.
Help XML enables localization and phrasing control of all labels and static UI and rule elements.
Custom theming supports both light and dark visual modes.
Collection support includes IEnumerable<T> properties, enabling iteration inside rules.
Keyboard and Gesture support provides intuitive rule authoring through extensive keyboard shortcuts and user gestures, including cut, copy, and paste of entire rule sections or individual elements.
Rule Persistence
Rules are stored as Rule XML documents under the <codeeffects> root element. Each document contains the rule structure, operator hierarchy, referenced sub-rules, and values.
Rule XML documents can be — and in most cases are — stored as plain strings, or, in databases, as nvarchar(max) fields containing the output of the XmlDocument.OuterXml value. This greatly simplifies the storage and transport of rules between systems and environments, since the entire rule definition remains a single, self-contained string that requires no serialization or decoding.
Rule Evaluation (Rule Engine)
The Rule Engine is a stand-alone, thread-safe .NET library that loads the Rule XML, compiles it in memory, and evaluates it against a provided source object. During this process, each rule is translated into Common Intermediate Language (CIL) code that becomes part of your application’s compiled logic. As a result, the performance of rule evaluation matches the overall performance of your project — limited only by the capabilities of the underlying hardware and network environment.
This architecture allows the Code Effects Rule Engine to operate with exceptional speed, safety, and efficiency in multi-threaded mission-critical systems. In performance tests, the engine has been shown to evaluate a rule containing a single condition against an array of 1 million randomly generated objects in approximately 0.015 seconds (15 milliseconds) on a single CPU — including the time required for rule compilation.
Capabilities include:
Evaluation Type rules that return true or false for any decision, no matter how complex.
Execution Type rules that also return true or false as the overall evaluation result, but are additionally capable of invoking any public, internal, or external methods — either as in-rule methods (methods used as fields within rule conditions) or as rule actions. This feature enables virtually unlimited capabilities, including data retrieval, communication with external systems or networks, file generation, user notification, and other custom processes declared in your public methods and invoked either during the evaluation of rule conditions or as a resulting action after the rule has been evaluated.
Rule-to-query translation via the Filter(..) method for LINQ data sources.
Parentheses-aware logic parsing, preserving AND/OR precedence exactly as authored.
Pre-compiled evaluators for high-throughput scenarios.
Rule Evaluation Example:
using CodeEffects.Rule.Engine;
public static class Demo
{
public static bool Evaluate(Customer data, string ruleXml)
{
var evaluator = new Evaluator<Customer>(ruleXml);
return evaluator.Evaluate(data);
}
}
For execution type rules, this same evaluation call triggers any field assignments or method calls defined inside the rule, while still returning a true or false result indicating whether any condition evaluated to true.
From Decision to Data Filtering
In Code Effects, every evaluation type business rule can optionally act as a data filter. When you apply the same rule to a collection or queryable dataset, the engine internally translates the rule conditions into a LINQ predicate.
Example rule:
Check if Order Amount is greater than 1000 and Order Status equals to Pending
Applied as a filter:
var filtered = orders.Filter(ruleXml);
Equivalent LINQ:
var filtered = orders.Where(o => o.Amount > 1000 && o.Status == "Pending");
In practice, this feature lets you reuse business rules to build dynamic, rule-driven search or reporting logic — but conceptually, it remains a secondary capability derived from the same decision logic.
Integration Workflow
- Add the Rule Editor to your application via NuGet.
- Expose either Source class, Source XML, or FlexSource describing your object model and allowed operations.
- Render the Editor in your web UI to let users author rules.
- Persist rules as XML in your rule storage layer.
- Load and evaluate rules in your backend using
Evaluator.Evaluate(..).
- (Optional) Apply rules as filters using
Evaluator.Filter(..) for analytical or selection tasks.
Supported Environments
- .NET Framework 4.6.2 and newer
- .NET Standard 2.0 and newer
- .NET 5.0 and newer
- ASP.NET WebForms / Core / MVC / Razor Pages / Blazor
- Xamarin and MAUI
- IIS or Kestrel-based hosts
- Google Cloud / AWS / MS Azure
Advantages of Code Effects Decision Automation
- True business ownership — domain experts can modify logic without coding.
- Consistent cross-layer behavior — the same rule drives both decisions and data filters.
- Parentheses-aware expressions — complex logical levels are preserved and readable.
- Auditable and version-safe — all rules stored as XML can be tracked and compared.
- No runtime dependencies — pure managed code, secure, and deployment-ready.
- Performance at scale — compiled, cached rule sets execute with minimal overhead.
- Extensible by design — developers can add custom attributes, actions, and parameters.
- Automatic rule validation — the editor validates every rule before it is saved or executed, ensuring that all conditions are complete, operands are compatible, and referenced fields or values exist. It also performs a circular-dependency check on all conditions and internally referenced rules, preventing infinite evaluation loops and guaranteeing rule consistency.
- Reusable rules — rules can reference and reuse other rules within the same ruleset, reducing duplication and improving maintainability. This allows complex logic to be composed from smaller, well-tested components.
- Rule templates — predefined rule structures can be provided to guide users in creating new rules that follow consistent business logic patterns or organizational policies.
- Multilingual support — the editor uses Help XML to define all operator names, messages, and UI labels, making it easy to localize the interface and rule text into any language.
- Web-based user interface — a unique, browser-native rule editor that can be embedded into any web application and accessed securely from anywhere, with no installation or client-side dependencies required.
- Thread-safe design — the engine is fully thread-safe, enabling concurrent rule evaluation across multiple threads or requests without shared-state conflicts. This makes Code Effects suitable for high-availability and mission-critical systems where stability, predictability, and scalability are essential.
Summary
Code Effects unifies decision logic, rule authoring, and rule execution within a single .NET framework. It enables both evaluation (pure decision) and execution (action-capable) rules, supports parentheses-based grouping for precise logic, and extends naturally into rule-driven data filtering when needed.
Built as a thread-safe, high-performance library, Code Effects is suitable for use in mission-critical systems where reliability and speed are essential. At its core, Code Effects is a decision-automation platform that bridges business intent and application behavior, transforming plain language into executable logic without sacrificing performance, clarity, or control.
Additional Resources