本文整理汇总了C#中INakedObject.ValidToPersist方法的典型用法代码示例。如果您正苦于以下问题:C# INakedObject.ValidToPersist方法的具体用法?C# INakedObject.ValidToPersist怎么用?C# INakedObject.ValidToPersist使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类INakedObject
的用法示例。
在下文中一共展示了INakedObject.ValidToPersist方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: IsReferenceValidToPersist
private bool IsReferenceValidToPersist(INakedObject target1) {
if (target1.ResolveState.IsTransient() ||
(target1.Oid is AggregateOid && ((AggregateOid)target1.Oid).ParentOid.IsTransient)) {
string validToPersist = target1.ValidToPersist();
if (validToPersist != null) {
ModelState.AddModelError("", validToPersist);
return false;
}
}
return true;
}
示例2: ValidateChanges
internal bool ValidateChanges(INakedObject nakedObject, ObjectAndControlData controlData, INakedObjectAssociation parent = null) {
List<INakedObjectAssociation> usableAndVisibleFields;
List<Tuple<INakedObjectAssociation, object>> fieldsAndMatchingValues;
GetUsableAndVisibleFields(nakedObject, controlData, parent, out usableAndVisibleFields, out fieldsAndMatchingValues);
CheckConcurrency(nakedObject, parent, controlData, GetConcurrencyFieldInputId);
fieldsAndMatchingValues.ForEach(pair => AddAttemptedValue(GetFieldInputId(parent, nakedObject, pair.Item1), pair.Item2));
// check mandatory fields first to emulate WPF UI behaviour where no validation takes place until
// all mandatory fields are set.
foreach (var pair in fieldsAndMatchingValues) {
var result = pair.Item2;
var stringResult = result as string;
if (pair.Item1.IsMandatory && (result == null || (result is string && string.IsNullOrEmpty(stringResult)))) {
AddErrorAndAttemptedValue(nakedObject, stringResult, pair.Item1, MvcUi.Mandatory, parent);
}
}
if (ModelState.IsValid) {
ValidateOrApplyInlineChanges(nakedObject, controlData, usableAndVisibleFields, ValidateChanges);
}
if (ModelState.IsValid) {
foreach (var pair in fieldsAndMatchingValues) {
if (!pair.Item1.IsCollection) {
ValidateAssociation(nakedObject, (IOneToOneAssociation) pair.Item1, pair.Item2, parent);
}
}
}
if (ModelState.IsValid) {
INakedObjectValidation[] validators = nakedObject.Specification.ValidateMethods();
foreach (INakedObjectValidation validator in validators) {
string[] parmNames = validator.ParameterNames;
var matchingparms = parmNames.Select(pn => fieldsAndMatchingValues.Single(t => t.Item1.Id.ToLower() == pn)).ToList();
if (matchingparms.Count() == parmNames.Count()) {
string result = validator.Execute(nakedObject, matchingparms.Select(t => GetNakedObjectValue(t.Item1, nakedObject, t.Item2)).ToArray());
if (!string.IsNullOrEmpty(result)) {
ModelState.AddModelError(string.Empty, result);
}
}
}
}
if (ModelState.IsValid) {
if (nakedObject.Specification.ContainsFacet<IValidateProgrammaticUpdatesFacet>()) {
string state = nakedObject.ValidToPersist();
if (state != null) {
ModelState.AddModelError(string.Empty, state);
}
}
}
return ModelState.IsValid;
}