怎样在自定义属性中进行四舍五入处理

来源:互联网 发布:西安软件开发培训班 编辑:程序博客网 时间:2024/06/16 01:18
从blog.org的我的原博客中迁入

发表时间:2007-3-18 12:29:53

要达到Math.Round(self.MemberPrice * (self.MemberHire.TaxRate / 100),2)

这样的效果,需要:

 public class MyOclOperationSQR: OclOperationBase
 {
  public override void Evaluate(IOclOperationParameters parameters)
  {
   double p1 = Support.GetAsNumeric(parameters.Values[1]);
   Support.MakeNewNumeric( parameters.Result, System.Math.Sqrt(p1) );
  }

  protected override void Init()
  {
   InternalInit("SQR", new IOclType[]{Support.AnyType, Support.RealType},
Support.RealType );
  }
 }

This operation should be initialized at EcoSpace init:

OclService.InstallOperation(new MyOclOperationSQR());

Then you're able to use SQR or ROUND in any OCL expression.

原创粉丝点击