本文整理汇总了C#中RuleContext.GetInputValue方法的典型用法代码示例。如果您正苦于以下问题:C# RuleContext.GetInputValue方法的具体用法?C# RuleContext.GetInputValue怎么用?C# RuleContext.GetInputValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类RuleContext
的用法示例。
在下文中一共展示了RuleContext.GetInputValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Execute
/// <summary>
/// Business or validation rule implementation.
/// </summary>
/// <param name="context">Rule context object.</param>
protected override void Execute(RuleContext context)
{
if (context == null)
throw new ArgumentNullException("context");
var value = context.GetInputValue(StringProperty);
if (!IsValid(value))
{
context.AddErrorResult(StringProperty, FormatErrorMessage(StringProperty.FriendlyName));
}
}
示例2: Execute
/// <summary>
/// Business or validation rule implementation.
/// </summary>
/// <param name="context">
/// Rule context object.
/// </param>
protected override void Execute(RuleContext context)
{
if (context == null)
throw new ArgumentNullException("context");
var value = context.GetInputValue(_primaryProperty) ?? string.Empty;
if (value.Length <= _maxLength)
return;
var message = string.Format(CultureInfo.CurrentCulture, LanguageService.Translate("Rule_StringLength"), GetPropertyName(), _maxLength);
context.AddErrorResult(message);
if (_mainProperty != null)
{
var editableRoot = context.Target as IEditableRoot;
if (editableRoot != null && ReferenceEquals(PrimaryProperty, editableRoot.GetLocalizedProperty(_mainProperty)))
{
context.AddErrorResult(_mainProperty, message);
}
}
}