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


C# IPackage.Validate方法代码示例

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


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

示例1: AnalyzePackage

        internal void AnalyzePackage(IPackage package)
        {
            IEnumerable<IPackageRule> packageRules = Rules;
            if (!String.IsNullOrEmpty(package.Version.SpecialVersion))
            {
                // If a package contains a special token, we'll warn users if it does not strictly follow semver guidelines.
                packageRules = packageRules.Concat(new[] { new StrictSemanticVersionValidationRule() });
            }

            IList<PackageIssue> issues = package.Validate(packageRules).OrderBy(p => p.Title, StringComparer.CurrentCulture).ToList();

            if (issues.Count > 0)
            {
                Console.WriteLine();
                Console.WriteWarning(NuGetResources.PackageCommandPackageIssueSummary, issues.Count, package.Id);
                foreach (var issue in issues)
                {
                    PrintPackageIssue(issue);
                }
            }
        }
开发者ID:nickfloyd,项目名称:NuGet,代码行数:21,代码来源:PackCommand.cs

示例2: AnalyzePackage

        internal void AnalyzePackage(IPackage package)
        {
            var packageRules = new List<IPackageRule>();
            foreach (var rule in Rules)
            {
                // Convert the aggregate DefaultPackageRules into a set of individual rules to allow for filtering.
                // We cannot modify the DefaultPackageRules.Rules since it may be used by extensions, such as the "analyze" one.
                if (rule is DefaultPackageRules)
                {
                    packageRules.AddRange(DefaultPackageRules.RuleSet);
                }
                else
                {
                    packageRules.Add(rule);
                }
            }

            if (!String.IsNullOrEmpty(package.Version.SpecialVersion))
            {
                // If a package contains a special token, we'll warn users if it does not strictly follow semver guidelines.
                packageRules.Add(new StrictSemanticVersionValidationRule());
            }

            if (!String.IsNullOrWhiteSpace(DisableRules))
            {
                var disabledRulesList = DisableRules.Split(new [] {';'}, StringSplitOptions.RemoveEmptyEntries);
                packageRules.RemoveAll(rule => disabledRulesList.Any(disabled => string.Equals(rule.GetType().Name, disabled, StringComparison.OrdinalIgnoreCase)));
            }

            if (Verbosity == Verbosity.Detailed)
            {
                Console.WriteLine(LocalizedResourceManager.GetString("PackageCommandEnabledRules"), string.Join(";", packageRules.Select(rule => rule.GetType().Name)));
            }

            IList<PackageIssue> issues = package.Validate(packageRules).OrderBy(p => p.Title, StringComparer.CurrentCulture).ToList();

            if (issues.Count > 0)
            {
                Console.WriteLine();
                Console.WriteWarning(LocalizedResourceManager.GetString("PackageCommandPackageIssueSummary"), issues.Count, package.Id);
                foreach (var issue in issues)
                {
                    PrintPackageIssue(issue);
                }
            }
        }
开发者ID:sistoimenov,项目名称:NuGet2,代码行数:46,代码来源:PackCommand.cs


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