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


C# ModelNode.RegIsExcludedFromValidation方法代码示例

本文整理汇总了C#中ModelNode.RegIsExcludedFromValidation方法的典型用法代码示例。如果您正苦于以下问题:C# ModelNode.RegIsExcludedFromValidation方法的具体用法?C# ModelNode.RegIsExcludedFromValidation怎么用?C# ModelNode.RegIsExcludedFromValidation使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在ModelNode的用法示例。


在下文中一共展示了ModelNode.RegIsExcludedFromValidation方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: ResolveModelValidation

        public static bool ResolveModelValidation(ModelNode modelNode, string start)
        {
            Trace.WriteLine(string.Format(""));

            var hasMissedOrInvalidProps = false;

            var model = modelNode.Value;
            Trace.WriteLine(string.Format("[INF] {2}MODEL CHECK [{0}] - ( {1} )", model.GetType(), model.ToString(), start));

            //if (model.RequireSelfProcessing || modelNode.Options.RequireSelfProcessing)
            if (modelNode.Options.RequireSelfProcessing)
            {
                var shouldProcessFlag = !modelNode.RegIsExcludedFromValidation();

                if (RegExcludedDefinitionTypes.Contains(modelNode.Value.GetType()))
                    shouldProcessFlag = false;

                if (shouldProcessFlag)
                {

                    var modelValidationResult = ModelValidations.FirstOrDefault(r => r.Model == model);

                    var shouldBeValidatedProperties = model.GetType()
                        .GetProperties()
                        .Where(
                            p =>
                                p.GetCustomAttributes<SPMeta2.Attributes.Regression.ExpectValidationAttribute>().Count() >
                                0)
                        .ToList();


                    if (modelValidationResult == null)
                    {
                        Trace.WriteLine(string.Format("[ERR]{2} Missing validation for model [{0}] - ( {1} )",
                            model.GetType(), model.ToString(), start));

                        hasMissedOrInvalidProps = true;
                        return hasMissedOrInvalidProps;
                    }

                    foreach (
                        var property in
                            modelValidationResult.Properties.OrderBy(p => p.Src != null ? p.Src.Name : p.ToString()))
                    {
                        if ((!property.IsValid) ||
                            (property.IsValid && !ShowOnlyFalseResults))
                        {
                            Trace.WriteLine(
                                string.Format(
                                    "[INF]{6} [{4}] - Src prop: [{0}] Src value: [{1}] Dst prop: [{2}] Dst value: [{3}] Message:[{5}]",
                                    new object[]
                                    {
                                        property.Src != null ? property.Src.Name : string.Empty,
                                        property.Src != null ? property.Src.Value : string.Empty,

                                        property.Dst != null ? property.Dst.Name : string.Empty,
                                        property.Dst != null ? property.Dst.Value : string.Empty,

                                        property.IsValid,
                                        property.Message,
                                        start
                                    }));
                        }

                        if (!property.IsValid)
                            hasMissedOrInvalidProps = true;

                    }

                    Trace.WriteLine(string.Format("[INF] {0}PROPERTY CHECK", start));

                    if (EnablePropertyValidation)
                    {
                        Trace.WriteLine(string.Format("[INF] {0}EnablePropertyValidation == true. Checking...", start));

                        foreach (var shouldBeValidatedProp in shouldBeValidatedProperties.OrderBy(p => p.Name))
                        {
                            var hasValidation = false;
                            var validationResult =
                                modelValidationResult.Properties.FirstOrDefault(
                                    r => r.Src != null && r.Src.Name == shouldBeValidatedProp.Name);

                            // convert stuff
                            if (validationResult == null)
                            {
                                validationResult = modelValidationResult.Properties.FirstOrDefault(
                                    r => r.Src != null && r.Src.Name.Contains("." + shouldBeValidatedProp.Name + ")"));
                            }

                            // nullables
                            if (validationResult == null)
                            {
                                validationResult = modelValidationResult.Properties.FirstOrDefault(
                                    r => r.Src != null &&
                                         (r.Src.Name.Contains("System.Nullable`1") &&
                                          r.Src.Name.Contains(shouldBeValidatedProp.Name)));
                            }

                            if (validationResult != null)
                            {
//.........这里部分代码省略.........
开发者ID:SubPointSolutions,项目名称:spmeta2-reverse,代码行数:101,代码来源:ReverseRegressionAssertService.cs


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