在 razorengine 中调用函数
Calling functions in razorengine
我正在使用 http://antaris.github.io/RazorEngine/ 从模板生成字符串,但在调用模板内的函数时遇到问题。该站点上的文档有点缺少示例,但我正在尝试使用一种格式调用 double
ToString 函数。格式字符串为:
"The value of sensor @Model.Measurement.Sensor.Description is out of spec with a value of ((double)@Model.AdjustedValue).ToString(\"#.##\")"
字符串的最后一部分我希望将输出四舍五入到最接近的百分之一,但我得到的不是以下字符串:
"The value of sensor Test_sensor_1 is out of spec with a value of ((double)78.14215625).ToString("#.##")"
有人可以指出我想要实现的目标的正确语法吗?
你的@
放错地方了,我觉得:
"The value of sensor @Model.Measurement.Sensor.Description is out of spec with a value of @(((double)Model.AdjustedValue).ToString(\"#.##\"))"
我正在使用 http://antaris.github.io/RazorEngine/ 从模板生成字符串,但在调用模板内的函数时遇到问题。该站点上的文档有点缺少示例,但我正在尝试使用一种格式调用 double
ToString 函数。格式字符串为:
"The value of sensor @Model.Measurement.Sensor.Description is out of spec with a value of ((double)@Model.AdjustedValue).ToString(\"#.##\")"
字符串的最后一部分我希望将输出四舍五入到最接近的百分之一,但我得到的不是以下字符串:
"The value of sensor Test_sensor_1 is out of spec with a value of ((double)78.14215625).ToString("#.##")"
有人可以指出我想要实现的目标的正确语法吗?
你的@
放错地方了,我觉得:
"The value of sensor @Model.Measurement.Sensor.Description is out of spec with a value of @(((double)Model.AdjustedValue).ToString(\"#.##\"))"