本文整理汇总了C#中Validator.MatchesCondition方法的典型用法代码示例。如果您正苦于以下问题:C# Validator.MatchesCondition方法的具体用法?C# Validator.MatchesCondition怎么用?C# Validator.MatchesCondition使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Validator
的用法示例。
在下文中一共展示了Validator.MatchesCondition方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: ValidateForm
/// <summary>
/// Validates user input data and returns the result.
/// </summary>
/// <param name="codeName">A code name of the media library.</param>
private bool ValidateForm(string codeName)
{
bool result = true;
txtDisplayName.Text = txtDisplayName.Text.Trim();
txtDescription.Text = txtDescription.Text.Trim();
txtFolder.Text = URLHelper.GetSafeFileName(txtFolder.Text.Trim(), CMSContext.CurrentSiteName);
List<Validator> validators = new List<Validator>(7);
validators.Add(new Validator().NotEmpty(txtDisplayName.Text, GetString("general.requiresdisplayname")));
validators.Add(new Validator().NotEmpty(codeName, GetString("general.requirescodename")).IsCodeName(codeName, GetString("general.invalidcodename")).MatchesCondition(codeName, x => IsCodeNameUnique(x), GetString("general.codenameexists")));
if (txtFolder.Enabled)
{
validators.Add(new Validator().NotEmpty(txtFolder.Text, GetString("media.error.FolderNameIsEmpty")).IsFolderName(txtFolder.Text, GetString("media.error.FolderNameIsNotValid")).MatchesCondition(txtFolder.Text, x => x != "." && x != "..", GetString("media.error.FolderNameIsRelative")).MatchesCondition(txtFolder.Text, x => IsFolderNameUnique(x), GetString("media.error.FolderExists")));
}
Validator teaserValidator = new Validator().MatchesCondition(ucMetaFile.IsValid(), x => x, ucMetaFile.ValidationError);
if (!teaserValidator.IsValid && (ucMetaFile.PostedFile != null) && MetaFileInfoProvider.StoreFilesInFileSystem(CMSContext.CurrentSiteName))
{
string path = MetaFileInfoProvider.GetFilesFolderPath(CMSContext.CurrentSiteName);
teaserValidator = teaserValidator.MatchesCondition(path, x => CanStoreTeaser(path), String.Format(GetString("media.AccessDeniedToPath"), path));
}
validators.Add(teaserValidator);
foreach (Validator validator in validators)
{
if (!validator.IsValid)
{
AddError(HTMLHelper.HTMLEncode(validator.Result), null);
result = false;
}
}
return result;
}