基本上,我有一个只需要小数条目的文本框,但有一个验证规则只允许在此文本框中使用小数。
这是我拥有的代码,但它没有做我想要的:
#Region " RULE: Decimal Value Required Rule "
Public Class DecimalRequiredRule
Inherits Rules.BusinessRule
Public Sub New(ByVal primaryProperty As Core.IPropertyInfo)
InputProperties = New List(Of IPropertyInfo)({primaryProperty})
Me.PrimaryProperty = primaryProperty
End Sub
Protected Overrides Sub Execute(ByVal context As Csla.Rules.RuleContext)
Try
Dim isDecimal As Decimal = CDec(context.InputPropertyValues(PrimaryProperty))
Catch ex As Exception
context.AddErrorResult(PrimaryProperty.FriendlyName & " must be a decimal")
End Try
End Sub
End Class
#End Region