Skip to content

Proposal for Interface Update #49

Description

@RenanCarlosPereira

Proposal for Interface Update

Objective:
Allow users to implement their own workflows and rules by updating method signatures in IRulesEngine.cs to use interfaces.

Current Issue:
Method signatures use Workflow and Rule classes directly, limiting extensibility.

Proposed Changes:

  1. Change Method Signatures:
    • Use IWorkflow instead of Workflow
    • Use IRule instead of Rule

Example Changes:

Current:

Task<List<RuleResultTree>> ExecuteAllRulesAsync(string workflowName, List<Workflow> workflows);
void AddRule(string workflowName, Rule rule);

Proposed:

Task<List<RuleResultTree>> ExecuteAllRulesAsync(string workflowName, List<IWorkflow> workflows);
void AddRule(string workflowName, IRule rule);

Extending Rule Example:

Current Rule Class:

public class Rule
{
    public string RuleName { get; set; }
    public string SuccessEvent { get; set; }
    public string ErrorMessage { get; set; }
    public string Expression { get; set; }
    public RuleExpressionType RuleExpressionType { get; set; }
    public Dictionary<string, object> Properties { get; set; }
}

Extended Rule Interface and Class for Generic Business Scenario:

Interface:

public interface IRule
{
    string RuleName { get; set; }
    string SuccessEvent { get; set; }
    string ErrorMessage { get; set; }
    string Expression { get; set; }
    RuleExpressionType RuleExpressionType { get; set; }
    Dictionary<string, object> Properties { get; set; }
    string Category { get; set; } // New property example
}

Custom Rule Implementation:

public class CustomRule : IRule
{
    public string RuleName { get; set; }
    public string SuccessEvent { get; set; }
    public string ErrorMessage { get; set; }
    public string Expression { get; set; }
    public RuleExpressionType RuleExpressionType { get; set; }
    public Dictionary<string, object> Properties { get; set; } = new Dictionary<string, object>();
    
    // New property
    public string Category { get; set; }
}

Usage in Business:
In a business scenario, a rule might need a Category property to classify rules into different segments like "Financial", "Operational", or "Compliance". This helps in organizing and managing rules more effectively.

Proposed IRulesEngine Changes:

Task<List<RuleResultTree>> ExecuteAllRulesAsync(string workflowName, List<IWorkflow> workflows);
void AddRule(string workflowName, IRule rule);

This change allows users to define custom rules with additional properties, such as categorization, enhancing the flexibility and applicability of the rules engine to real-world business scenarios.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions