Quantcast
Channel: ClearScript
Viewing all articles
Browse latest Browse all 2297

Created Unassigned: ClearScript V8ScriptEngine Arithmetic [63]

$
0
0
Hello,

I need help about clearscript. I am using class and this class has a variable. Example is under.

public class DataDict
{
public decimal AmountPenetrationBonus { get; set; }
public decimal TermFactor { get; set; }
public decimal ConstantBonus { get; set; }
public decimal BonusForOtherCreditTypes { get; set; }
public decimal CampaignExponent { get; set; }
public String Formula { get; set; }
}

DataDict dataDict = new DataDict();
dataDict.AmountPenetrationBonus = 5;
dataDict.TermFactor = 2;
dataDict.ConstantBonus = 3;
dataDict.BonusForOtherCreditTypes = 4;
dataDict.CampaignExponent = 2;
dataDict.Formula = AmountPenetrationBonus*TermFactor *ConstantBonus ;

and my script is
using (var engine = new V8ScriptEngine())
{

engine.AddHostObject("DataDict", dataDict);
engine.Execute(@"AmountPenetrationBonus= DataDict.AmountPenetrationBonus;
TermFactor=DataDict.TermFactor;
ConstantBonus = DataDict.ConstantBonus;
BonusForOtherCreditTypes=DataDict.BonusForOtherCreditTypes;
CampaignExponent = DataDict.CampaignExponent;
result = DataDict.Formula;
");
var result = engine.Script.result;
}
but return the result value =AmountPenetrationBonus*TermFactor *ConstantBonus , it was be 5*2*3 than return to me 30. engine.Script.result return to me the string value doesnt decimal value.
Please help about this problem.

Thanks for help and sorry for my english.

Viewing all articles
Browse latest Browse all 2297

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>