• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# RuleSet类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中RuleSet的典型用法代码示例。如果您正苦于以下问题:C# RuleSet类的具体用法?C# RuleSet怎么用?C# RuleSet使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



RuleSet类属于命名空间,在下文中一共展示了RuleSet类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: TryUpdateExistingProjectRuleSet

        internal /*for testing purposes*/ bool TryUpdateExistingProjectRuleSet(string solutionRuleSetPath, string projectRuleSetRootFolder, string currentRuleSet, out string existingRuleSetPath, out RuleSet existingRuleSet)
        {
            existingRuleSetPath = null;
            existingRuleSet = null;

            if (ShouldIgnoreConfigureRuleSetValue(currentRuleSet))
            {
                return false;
            }

            existingRuleSetPath = PathHelper.ResolveRelativePath(currentRuleSet, projectRuleSetRootFolder);
            if (!PathHelper.IsPathRootedUnderRoot(existingRuleSetPath, projectRuleSetRootFolder))
            {
                // Not our file (i.e. absolute path to some other ruleset)
                existingRuleSetPath = null;
                return false;
            }

            if (this.AlreadyUpdatedExistingRuleSetPaths.TryGetValue(existingRuleSetPath, out existingRuleSet))
            {
                return true;
            }

            existingRuleSet = this.ruleSetSerializer.LoadRuleSet(existingRuleSetPath);
            if (existingRuleSet == null)
            {
                existingRuleSetPath = null;
                return false;
            }

            RuleSetHelper.UpdateExistingProjectRuleSet(existingRuleSet, solutionRuleSetPath);
            this.AlreadyUpdatedExistingRuleSetPaths.Add(existingRuleSetPath, existingRuleSet);
            return true;
        }
开发者ID:SonarSource-VisualStudio,项目名称:sonarlint-visualstudio,代码行数:34,代码来源:ProjectBindingOperation.Writer.cs


示例2: GetSelectorNameInternal

        private string GetSelectorNameInternal(RuleSet ruleSet)
        {
            var currentSelectorName = base.GetSelectorName(ruleSet).Trim();
            var currentSet = ruleSet;
            var currentBlock = ruleSet.Parent as LessRuleBlock;

            while (currentSet != null && currentBlock != null)
            {
                currentSet = currentBlock.Parent as RuleSet;

                if (currentSet != null)
                {
                    currentSelectorName = base.GetSelectorName(currentSet).Trim() + " " + currentSelectorName;
                    currentBlock = currentSet.Parent as LessRuleBlock;
                }
            }

            var name = currentSelectorName.Replace(" &", "");
            var oldName = name;

            while (oldName != (name = name.Replace(" >", ">").Replace("> ", ">")))
            {
                oldName = name;
            }

            return oldName.Replace(">", " > ");
        }
开发者ID:robert-hoffmann,项目名称:WebEssentials2013,代码行数:27,代码来源:LessDocument.cs


示例3: GetSelectorNames

        public static IEnumerable<string> GetSelectorNames(RuleSet ruleSet, LessMixinAction mixinAction)
        {
            if (ruleSet.Selectors.Any(s => s.SimpleSelectors.Any(ss => ss.SubSelectors.Any(sss => sss is LessMixinDeclaration))))
            {
                switch (mixinAction)
                {
                    case LessMixinAction.Skip:
                        return Enumerable.Empty<string>();
                    case LessMixinAction.Literal:
                        break;
                    case LessMixinAction.NestedOnly:
                        var mixinDecl = ruleSet.Selectors.SelectMany(s => s.SimpleSelectors.SelectMany(ss => ss.SubSelectors.OfType<LessMixinDeclaration>())).First();
                        return Enumerable.Repeat("«mixin " + mixinDecl.MixinName.Name + "»", 1);
                }
            }

            var parentBlock = ruleSet.FindType<LessRuleBlock>();

            if (parentBlock == null)
                return ruleSet.Selectors.Select(CssExtensions.SelectorText);

            var parentSet = parentBlock.FindType<RuleSet>();

            if (parentSet == null)
                return ruleSet.Selectors.Select(CssExtensions.SelectorText);

            // Cache the computed parents to avoid re-computing them
            // for every child permutation.
            var parentSelectors = GetSelectorNames(parentSet, mixinAction).ToList();

            return ruleSet.Selectors.SelectMany(child =>
                CombineSelectors(parentSelectors, child.SelectorText())
            );
        }
开发者ID:ChrisTorng,项目名称:WebEssentials2013,代码行数:34,代码来源:LessDocument.cs


示例4: FindRuleSetInFile

        private string FindRuleSetInFile(IEnumerable<string> extensions, string className, out RuleSet rule)
        {
            string root = ProjectHelpers.GetProjectFolder(peekableItem._textbuffer.GetFileName());
            string result = null;
            bool isLow = false, isMedium = false;
            rule = null;

            foreach (string ext in extensions)
            {
                ICssParser parser = CssParserLocator.FindComponent(Mef.GetContentType(ext.Trim('.'))).CreateParser();

                foreach (string file in Directory.EnumerateFiles(root, "*" + ext, SearchOption.AllDirectories))
                {
                    if (file.EndsWith(".min" + ext, StringComparison.OrdinalIgnoreCase) ||
                        file.Contains("node_modules") ||
                        file.Contains("bower_components"))
                        continue;

                    string text = FileHelpers.ReadAllTextRetry(file).ConfigureAwait(false).GetAwaiter().GetResult();
                    int index = text.IndexOf("." + className, StringComparison.Ordinal);

                    if (index == -1)
                        continue;

                    var css = parser.Parse(text, true);
                    var visitor = new CssItemCollector<ClassSelector>(false);
                    css.Accept(visitor);

                    var selectors = visitor.Items.Where(c => c.ClassName.Text == className);
                    var high = selectors.FirstOrDefault(c => c.FindType<AtDirective>() == null && (c.Parent.NextSibling == null || c.Parent.NextSibling.Text == ","));

                    if (high != null)
                    {
                        rule = high.FindType<RuleSet>();
                        return file;
                    }

                    var medium = selectors.FirstOrDefault(c => c.Parent.NextSibling == null || c.Parent.NextSibling.Text == ",");

                    if (medium != null && !isMedium)
                    {
                        rule = medium.FindType<RuleSet>();
                        result = file;
                        isMedium = true;
                        continue;
                    }

                    var low = selectors.FirstOrDefault();

                    if (low != null && !isLow && !isMedium)
                    {
                        rule = low.FindType<RuleSet>();
                        result = file;
                        isLow = true;
                    }
                }
            }

            return result;
        }
开发者ID:venux,项目名称:WebEssentials2015,代码行数:60,代码来源:ClassPeekResultSource.cs


示例5: RuleSetDialog

        public RuleSetDialog(Activity activity, RuleSet ruleSet)
        {
            if (activity == null)
                throw (new ArgumentNullException("activity"));

            InitializeDialog(ruleSet);

            ITypeProvider typeProvider;
            this.serviceProvider = activity.Site;
            if (this.serviceProvider != null)
            {
                typeProvider = (ITypeProvider)this.serviceProvider.GetService(typeof(ITypeProvider));
                if (typeProvider == null)
                {
                    string message = string.Format(CultureInfo.CurrentCulture, Messages.MissingService, typeof(ITypeProvider).FullName);
                    throw new InvalidOperationException(message);
                }

                WorkflowDesignerLoader loader = this.serviceProvider.GetService(typeof(WorkflowDesignerLoader)) as WorkflowDesignerLoader;
                if (loader != null)
                    loader.Flush();

            }
            else
            {
                // no service provider, so make a TypeProvider that has all loaded Assemblies
                TypeProvider newProvider = new TypeProvider(null);
                foreach (Assembly a in AppDomain.CurrentDomain.GetAssemblies())
                    newProvider.AddAssembly(a);
                typeProvider = newProvider;
            }

            RuleValidation validation = new RuleValidation(activity, typeProvider, false);
            this.ruleParser = new Parser(validation);
        }
开发者ID:nlh774,项目名称:DotNetReferenceSource,代码行数:35,代码来源:RuleSetDialog.cs


示例6: GetSelectorNames

        public static IEnumerable<string> GetSelectorNames(RuleSet ruleSet, ScssMixinAction mixinAction)
        {
            if (ruleSet.Block.Directives.Any(d => d is ScssMixinDirective))
            {
                switch (mixinAction)
                {
                    case ScssMixinAction.Skip:
                        return Enumerable.Empty<string>();
                    case ScssMixinAction.Literal:
                        break;
                }
            }

            var parentBlock = ruleSet.FindType<ScssRuleBlock>();

            if (parentBlock == null)
                return ruleSet.Selectors.Select(CssExtensions.SelectorText);

            var parentSet = parentBlock.FindType<RuleSet>();

            if (parentSet == null)
                return ruleSet.Selectors.Select(CssExtensions.SelectorText);

            // Cache the computed parents to avoid re-computing them
            // for every child permutation.
            var parentSelectors = GetSelectorNames(parentSet, mixinAction).ToList();

            return ruleSet.Selectors.SelectMany(child =>
                CombineSelectors(parentSelectors, child.SelectorText())
            );
        }
开发者ID:EdsonF,项目名称:WebEssentials2013,代码行数:31,代码来源:ScssDocument.cs


示例7: GetScssSelectorName

        internal static string GetScssSelectorName(RuleSet ruleSet, bool includeShellSelectors = true)
        {
            if (!includeShellSelectors)
            {
                var block = ruleSet.Block as ScssRuleBlock;

                if (block == null || ruleSet.Block.Declarations.Count == 0 && ruleSet.Block.Directives.Count == 0 && block.RuleSets.Any())
                {
                    //If we got here, the element won't be included in the output but has children that might be
                    return null;
                }
            }

            string name = string.Join(",\r\n", GetSelectorNames(ruleSet, ScssMixinAction.Skip));

            if (name.Length == 0)
                return null;

            var oldName = name;

            while (oldName != (name = name.Replace(" >", ">").Replace("> ", ">")))
            {
                oldName = name;
            }

            return oldName.Replace(">", " > ");
        }
开发者ID:EdsonF,项目名称:WebEssentials2013,代码行数:27,代码来源:ScssDocument.cs


示例8: CssRule

        private CssRule(string sourceFile, string fileText, RuleSet ruleSet, string selectorName)
        {
            SelectorName = selectorName;
            CleansedSelectorName = RuleRegistry.StandardizeSelector(SelectorName);
            DisplaySelectorName = SelectorName.Replace('\r', '\n').Replace("\n", "").Trim();

            string oldDisplaySelectorName = null;

            while (DisplaySelectorName != oldDisplaySelectorName)
            {
                oldDisplaySelectorName = DisplaySelectorName;
                DisplaySelectorName = DisplaySelectorName.Replace("  ", " ");
            }

            File = sourceFile;

            int line, column;

            CalculateLineAndColumn(fileText, ruleSet, out line, out column);
            Line = line;
            Column = column;
            Offset = ruleSet.Range.Start;
            Length = ruleSet.Range.Length;

            var lastSelector = ruleSet.Selectors[ruleSet.Selectors.Count - 1];

            SelectorLength = lastSelector.Length + lastSelector.Start - ruleSet.Selectors[0].Start;
            _ruleSet = ruleSet;
        }
开发者ID:venux,项目名称:WebEssentials2015,代码行数:29,代码来源:CssRule.cs


示例9: Fire

        public string Fire(Unit target)
        {
            string result = string.Empty;

            RuleSet idealHitRules = new RuleSet();
            idealHitRules.Add(new UnderMaximumIdealRangeRule(this, target));
            idealHitRules.Add(new OverMinimumIdealRangeRule(this, target));

            RuleSet regularHitRules = new RuleSet();
            regularHitRules.Add(new UnderMaximumRangeRule(this, target));
            regularHitRules.Add(new OverMinimumRangeRule(this, target));

            //Fire!
            if (idealHitRules.Validate())
            {
                result = "Ideal hit!";
            }
            else if (regularHitRules.Validate())
            {
                result = "Hit.";
            }
            else
            {
                result = regularHitRules.FailureMessages[0];
            }

            return result;
        }
开发者ID:Dan-Landberg,项目名称:HurfDurf-Sample-Rule-Engine,代码行数:28,代码来源:Unit.cs


示例10: Verifies_SimpleTrueRules

        public void Verifies_SimpleTrueRules()
        {
            var propertiesForObject = new Dictionary<object, object> { { "phrase_count", 2 }, { "length", 10 } };

            var ruleSet = new RuleSet(new Rule[] { new GreaterThan("phrase_count", 1), new LessThan("length", 15) });

            Assert.That(ruleSet.VerifiedBy(propertiesForObject), Is.True);
        }
开发者ID:morenocarullo,项目名称:MachineLearning.NET,代码行数:8,代码来源:RuleSet.Tests.cs


示例11: Verifies_SimpleFalseRule

        public void Verifies_SimpleFalseRule()
        {
            var propertiesForObject = new Dictionary<object, object> { { "phrase_count", 1 } };

            var ruleSet = new RuleSet (new[]{new GreaterThan("phrase_count", 3)});

            Assert.That(ruleSet.VerifiedBy(propertiesForObject), Is.False);
        }
开发者ID:morenocarullo,项目名称:MachineLearning.NET,代码行数:8,代码来源:RuleSet.Tests.cs


示例12: EmptyRuleSet_AlwaysTrue

        public void EmptyRuleSet_AlwaysTrue()
        {
            var ruleSet = new RuleSet(new Rule[0]);

            var propertiesForObject = new Dictionary<object, object> { { "phrase_count", 2 }, { "length", 10 } };

            Assert.That(ruleSet.VerifiedBy(propertiesForObject));
        }
开发者ID:morenocarullo,项目名称:MachineLearning.NET,代码行数:8,代码来源:RuleSet.Tests.cs


示例13: CanUsePrintCommand

        public void CanUsePrintCommand()
        {
            var rs = new RuleSet();
            var c = Setup( rs, new[] { ">fire", ">water", "energy", "?fire" } );
            c.Cook();

            Assert.AreEqual( 3, rs.FoundElements.Length );
        }
开发者ID:Zazcallabah,项目名称:Alchemist,代码行数:8,代码来源:ChemistTests.cs


示例14: TestFirstReturnsDefaultResultWhereNoConditionIsMet

		public void TestFirstReturnsDefaultResultWhereNoConditionIsMet()
		{
			var ruleSet = new RuleSet<object,object,string>("default");

			ruleSet.When(equal).Then("equal");

			Assert.That(ruleSet.First("foo", "bar"), Is.EqualTo("default"));
		}
开发者ID:jamesottaway,项目名称:RuleSet.cs,代码行数:8,代码来源:RuleSetTests.cs


示例15: TestPassingGenericTypeToWhenInsteadOfFunc

		public void TestPassingGenericTypeToWhenInsteadOfFunc()
		{
			var ruleSet = new RuleSet<int, string>();

			ruleSet.When(1).Then("one");

			Assert.That(ruleSet.First(1), Is.EqualTo("one"));
		}
开发者ID:JBTech,项目名称:RuleSet.cs,代码行数:8,代码来源:RuleSetTests.cs


示例16: Equality_True

        public void Equality_True()
        {
            var ruleSet = new RuleSet(new[] { new EqualTo("ciao", 1) });

            var propertiesForObject = new Dictionary<object, object> { { "ciao", 1 }, { "length", 10 } };

            Assert.That(ruleSet.VerifiedBy(propertiesForObject), Is.True);
        }
开发者ID:morenocarullo,项目名称:MachineLearning.NET,代码行数:8,代码来源:RuleSet.Tests.cs


示例17: AlchemyControllerRecommendsNullIfNoElements

        public void AlchemyControllerRecommendsNullIfNoElements()
        {
            var rs = new RuleSet();
            var controller = new AlchemyController( rs );

            var rule = controller.RecommendNewRule();

            Assert.IsNull( rule );
        }
开发者ID:Zazcallabah,项目名称:Alchemist,代码行数:9,代码来源:AlchemyTests.cs


示例18: TestFirstReturnsFirstResultWhereTheConditionIsMet

		public void TestFirstReturnsFirstResultWhereTheConditionIsMet()
		{
			var ruleSet = new RuleSet<object,object,string>();

			ruleSet.When(equal).Then("equal");
			ruleSet.When(equal).Then("definitely equal");

			Assert.That(ruleSet.First("foo", "foo"), Is.EqualTo("equal"));
		}
开发者ID:jamesottaway,项目名称:RuleSet.cs,代码行数:9,代码来源:RuleSetTests.cs


示例19: AssertRuleSetsAreEqual

        public void AssertRuleSetsAreEqual(string ruleSetPath, RuleSet expectedRuleSet)
        {
            this.AssertRuleSetExists(ruleSetPath);

            RuleSet actualRuleSet = this.savedRuleSets[ruleSetPath];

            Assert.IsNotNull(actualRuleSet, "Expected rule set to be written");
            RuleSetAssert.AreEqual(expectedRuleSet, actualRuleSet);
        }
开发者ID:duncanpMS,项目名称:sonarlint-visualstudio,代码行数:9,代码来源:ConfigurableRuleSetSerializer.cs


示例20: CreateTestRuleSetWithRuleIds

 public static RuleSet CreateTestRuleSetWithRuleIds(IEnumerable<string> ids, string analyzerId = "TestId", string ruleNamespace = "TestNamespace", RuleSet existingRuleSet = null)
 {
     var ruleSet = existingRuleSet ?? new RuleSet("Test Rule Set");
     foreach (var id in ids)
     {
         ruleSet.Rules.Add(new RuleReference(analyzerId, ruleNamespace, id, RuleAction.Warning));
     }
     return ruleSet;
 }
开发者ID:SonarSource-VisualStudio,项目名称:sonarlint-visualstudio,代码行数:9,代码来源:TestRuleSetHelper.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Rule_Context类代码示例发布时间:2022-05-24
下一篇:
C# RuleDispatcher类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap