I stuck in a scenario while evaluating the rule it initializes the class B and calls the default constructor, but I am injecting the Db Connection through parameter constructor. Please see the below code and advice.
public class A
{
[ExternalMethod(typeof(B), "IsSpecialWord")]
[Field(DisplayName = "English Word", Description = "English Word", Max = 200)]
public string EngWord { get; set; }
}
public class B
{
public IDbCoonection dbCon { get; set; }
public B(IDbConnection db)
{
dbCon = db;
}
[Method("Is Special Word", "Indicates to test abbreviated word")]
public IsSpecialWord(sting word)
{
db.CheckSpecialWord(word);
}
public insert SpecialWord(T t)
{
db.Insert();
}
public update SpecialWord(T t)
{
db.Update();
}
}
public class TestController
{
A aObj = new A();
aObj.EngWord ="test";
IDbConnection db = null;
if(1)
db = new SQLDBConnection(connString);
else
db = new OracleDBConnection(connectionString);
B b = new B(db);
Evaluator<A> evaluator = new Evaluator<A>(editor.Rule.GetRuleXml());
bool success = evaluator.Evaluate(aObj);
}