'Create new DateTime in Microsoft RulesEngine rule

I'm looking at the Microsoft RulesEngine. This appears to have what I'm looking for but I'm having difficulties getting some of my rules to execute. I have a need to dynamically set/check date times for the customer's rules. I can do this in code and pass it into the ruleset, but I want to eliminate the need to recompile my app to send input values should they decide to change their rules. Having everything in my json file is the optimal solution here. I can then modify the rules, resend a json and call it done.

Here's the scenario: If a person has a license and they are renewing between certain dates then they should get a specific cost. Yes, it's a bit contrived but it's what I need to meet the acceptance criteria. The following doesn't work. Any recommendations/pointers? Thank you in advance!

Here's the sample:

[
    {
        "WorkflowName": "WithinRenewalPeriod",
        "GlobalParams": [
            {
                "Name": "Last_December",
                "Expression": "new DateTime(DateTime.Now.Year - 1 , 12, 1)"
            },
            {
                "Name": "Current_March",
                "Expression": "new DateTime(DateTime.Now.Year, 3, 1)"
            },
            {
                "Name": "Current_July",
                "Expression": "new DateTime(DateTime.Now.Year, 7, 10)"
            }
        ],
        "Rules": [
            {
                "RuleName": "PriorLicense_Between_Dec1_Mar1",
                "Enabled": true,
                "ErrorType": 0,
                "RuleExpressionType": 0,
                "Expression": "person.HistoricalLicenseList.Count() > 0 AND (DateTime.Now >= Last_December AND DateTime.Now <= Current_March)",
                "SuccessEvent": "1"
            },
            {
                "RuleName": "HasPriorLicense_Between_Mar2_July10",
                "Enabled": true,
                "ErrorType": 0,
                "RuleExpressionType": 0,
                "Expression": "person.HistoricalLicenseList.Count() > 0 AND (DateTime.Now >= Current_March AND DateTime.Now <= Current_July)",
                "SuccessEvent": "3000"
            }
        ]
    }
]


Solution 1:[1]

I figured it out. I was assuming that you would need to "new" the DateTime. This wasn't the case. I ended up removing the "new" keyword and was able to get the GlobalParams to work:

This is wrong:

Incorrect

This is the correct way to instantiate "new" DateTime in GlobalParams:

The correct way

The end results generated as Inputs:

Inputs result for GlobalParams

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Ayrab