当前位置: 首页>>代码示例>>C#>>正文


C# TreeNode.AddValidationError方法代码示例

本文整理汇总了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;
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:82,代码来源:FolderRangesFactory.cs

示例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;
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:67,代码来源:FolderRangesFactory.cs

示例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;
            }
        }
开发者ID:DBailey635,项目名称:C1-CMS,代码行数:84,代码来源:FolderRangesCreator.cs


注:本文中的TreeNode.AddValidationError方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。