本文整理汇总了C#中TreeNode.AddValidationError方法的典型用法代码示例。如果您正苦于以下问题:C# TreeNode.AddValidationError方法的具体用法?C# TreeNode.AddValidationError怎么用?C# TreeNode.AddValidationError使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TreeNode
的用法示例。
在下文中一共展示了TreeNode.AddValidationError方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: CreateStringFolderRanges
public static IFolderRanges CreateStringFolderRanges(TreeNode ownerTreeNode, List<Tuple<string, string>> ranges, bool includeWildCard)
{
StringFolderRanges folderRanges = new StringFolderRanges();
int counter = 0;
string lastMaxValue = null;
foreach (Tuple<string, string> range in ranges)
{
string minValue = "";
string maxValue = "";
bool isMinOpenEnded = range.Item1 == "";
bool isMaxOpenEnded = range.Item2 == "";
if (range.Item1 != "")
{
if (range.Item1.Length != 1)
{
ownerTreeNode.AddValidationError("TreeValidationError.Range.WrongFormat");
return null;
}
else
{
minValue = range.Item1;
}
}
if (range.Item2 != "")
{
if (range.Item2.Length != 1)
{
ownerTreeNode.AddValidationError("TreeValidationError.Range.WrongFormat");
return null;
}
else
{
maxValue = range.Item2;
}
}
if ((isMinOpenEnded == false) && (isMaxOpenEnded == false) && (string.Compare(minValue, maxValue) >= 0))
{
ownerTreeNode.AddValidationError("TreeValidationError.Range.MinMaxError", minValue, maxValue);
return null;
}
if (lastMaxValue == null)
{
lastMaxValue = maxValue;
}
else if (string.Compare(lastMaxValue, minValue) >= 0)
{
ownerTreeNode.AddValidationError("TreeValidationError.Range.NextRangeError");
}
StringFolderRange folderRange = new StringFolderRange(
counter++,
minValue,
maxValue,
isMinOpenEnded,
isMaxOpenEnded
);
folderRanges.AddFolderRange(folderRange);
}
if (includeWildCard)
{
StringFolderRange folderRange = new StringFolderRange(
-1,
"",
"",
false,
false
);
folderRanges.AddFolderRange(folderRange);
}
return folderRanges;
}
示例2: CreateIntFolderRangeIterator
public static IFolderRanges CreateIntFolderRangeIterator(TreeNode ownerTreeNode, List<Tuple<string, string>> ranges, bool includeWildCard)
{
IntFolderRanges folderRanges = new IntFolderRanges();
int counter = 0;
int? lastMaxValue = null;
foreach (Tuple<string, string> range in ranges)
{
int minValue = 0;
int maxValue = 0;
bool isMinOpenEnded = range.Item1 == "";
bool isMaxOpenEnded = range.Item2 == "";
if ((range.Item1 != "") && (int.TryParse(range.Item1, out minValue) == false))
{
ownerTreeNode.AddValidationError("TreeValidationError.Range.WrongFormat");
return null;
}
if ((range.Item2 != "") && (int.TryParse(range.Item2, out maxValue) == false))
{
ownerTreeNode.AddValidationError("TreeValidationError.Range.WrongFormat");
return null;
}
if ((isMinOpenEnded == false) && (isMaxOpenEnded == false) && (minValue >= maxValue))
{
ownerTreeNode.AddValidationError("TreeValidationError.Range.MinMaxError", minValue, maxValue);
return null;
}
if (lastMaxValue.HasValue == false)
{
lastMaxValue = maxValue;
}
else if (lastMaxValue.Value >= minValue)
{
ownerTreeNode.AddValidationError("TreeValidationError.Range.NextRangeError");
}
IntFolderRange folderRange = new IntFolderRange(
counter++,
minValue,
maxValue,
isMinOpenEnded,
isMaxOpenEnded
);
folderRanges.AddFolderRange(folderRange);
}
if (includeWildCard)
{
IntFolderRange folderRange = new IntFolderRange(
-1,
0,
0,
false,
false
);
folderRanges.AddFolderRange(folderRange);
}
return folderRanges;
}
示例3: Create
public static IFolderRanges Create(TreeNode ownerTreeNode, string rangeString, string fieldName, Type propertyType)
{
string[] rangesSplit = rangeString.Split(',');
bool includeWildCard = false;
List<string> rangeStrings = new List<string>();
foreach (string rangeSplit in rangesSplit)
{
string range = rangeSplit.Trim();
if (range != "*")
{
rangeStrings.Add(range);
}
else
{
includeWildCard = true;
}
}
if (rangeStrings.Count == 0)
{
ownerTreeNode.AddValidationError("TreeValidationError.Range.WrongFormat");
return null;
}
List<Tuple<string, string>> ranges = new List<Tuple<string, string>>();
if (rangeStrings.Count == 1)
{
Tuple<string, string> range = ValidateRange(rangeStrings[0], allowMinOpenEnded: true, allowMaxOpenEnded: true);
if (range == null)
{
ownerTreeNode.AddValidationError("TreeValidationError.Range.WrongFormat");
return null;
}
ranges.Add(range);
}
else if (rangeStrings.Count > 1)
{
string firstString = rangeStrings[0];
string lastString = rangeStrings[rangeStrings.Count - 1];
Tuple<string, string> firstRange = ValidateRange(firstString, allowMinOpenEnded: true);
Tuple<string, string> lastRange = ValidateRange(lastString, allowMaxOpenEnded: true);
if ((firstRange == null) || (lastRange == null))
{
ownerTreeNode.AddValidationError("TreeValidationError.Range.WrongFormat");
return null;
}
ranges.Add(firstRange);
for (int i = 1; i <= rangeStrings.Count - 2; i++)
{
Tuple<string, string> range = ValidateRange(rangeStrings[i]);
if (range == null)
{
ownerTreeNode.AddValidationError("TreeValidationError.Range.WrongFormat");
return null;
}
ranges.Add(range);
}
ranges.Add(lastRange);
}
if (propertyType == typeof(int))
{
return FolderRangesFactory.CreateIntFolderRangeIterator(ownerTreeNode, ranges, includeWildCard);
}
else if (propertyType == typeof(string))
{
return FolderRangesFactory.CreateStringFolderRanges(ownerTreeNode, ranges, includeWildCard);
}
else
{
ownerTreeNode.AddValidationError("TreeValidationError.Range.UnsupportedType", fieldName, propertyType);
return null;
}
}