本文整理汇总了C#中DomainObject.GetClass方法的典型用法代码示例。如果您正苦于以下问题:C# DomainObject.GetClass方法的具体用法?C# DomainObject.GetClass怎么用?C# DomainObject.GetClass使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类DomainObject
的用法示例。
在下文中一共展示了DomainObject.GetClass方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GetMessage
protected virtual string GetMessage(DomainObject obj)
{
return string.Format(SR.RuleUniqueKey, TerminologyTranslator.Translate(obj.GetClass(), _logicalKeyName),
TerminologyTranslator.Translate(_entityClass));
}
示例2: Validate
/// <summary>
/// Validates the specified domain object, ignoring any rules that do not satisfy the filter.
/// </summary>
/// <param name="obj"></param>
/// <param name="level"></param>
/// <param name="ruleFilter"></param>
/// <exception cref="EntityValidationException">Validation failed.</exception>
private void Validate(DomainObject obj, RuleLevel level, Predicate<ISpecification> ruleFilter)
{
var domainClass = obj.GetClass();
var ruleSets = new List<ISpecification>();
if (CheckLevel(level, RuleLevel.Low))
{
// first check for a cached rule-set
ValidationRuleSet lowLevelRules;
if (!_lowLevelRuleSets.TryGetValue(domainClass, out lowLevelRules))
{
// otherwise build it
lowLevelRules = IsValidationEnabled(domainClass) ?
ValidationRuleSetCache.GetLowLevelRules(domainClass)
: new ValidationRuleSet();
// cache for future use
_lowLevelRuleSets.Add(domainClass, lowLevelRules);
}
ruleSets.Add(lowLevelRules);
}
if (CheckLevel(level, RuleLevel.High))
{
// first check for a cached rule-set
ValidationRuleSet highLevelRules;
if (!_highLevelRuleSets.TryGetValue(domainClass, out highLevelRules))
{
// otherwise build it
highLevelRules = IsValidationEnabled(domainClass) ?
ValidationRuleSetCache.GetHighLevelRules(domainClass)
: new ValidationRuleSet();
// cache for future use
_highLevelRuleSets.Add(domainClass, highLevelRules);
}
ruleSets.Add(highLevelRules);
}
var rules = new ValidationRuleSet(ruleSets);
var result = rules.Test(obj, ruleFilter);
if (result.Fail)
{
var message = string.Format(SR.ExceptionInvalidEntity, TerminologyTranslator.Translate(obj.GetClass()));
throw new EntityValidationException(message, result.Reasons);
}
}