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


C# Context.AppendSelectors方法代码示例

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


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

示例1: AppendCSS

        protected virtual void AppendCSS(Env env, Context context)
        {
            var css = new List<string>(); // The CSS output
            var rules = new List<StringBuilder>(); // node.Ruleset instances
            var paths = new Context(); // Current selectors
            bool isRoot = this is Root;

            if (!isRoot)
            {
                paths.AppendSelectors(context, Selectors);
            }

            env.Output.Push();

            foreach (var node in Rules)
            {
                if (node.IgnoreOutput())
                    continue;

                var comment = node as Comment;
                if(comment != null && comment.Silent)
                    continue;

                var ruleset = node as Ruleset;
                if (ruleset != null)
                {
                    ruleset.AppendCSS(env, paths);
                }
                else {
                    var rule = node as Rule;
                    if ((rule != null && !rule.Variable) || (rule == null && !isRoot))
                    {
                        env.Output.Push();
                        node.AppendCSS(env);
                        rules.Add(env.Output.Pop());
                    }
                    else if (rule == null)
                    {
                        node.AppendCSS(env);
                    }
                }
            }

            var rulesetOutput = env.Output.Pop();

            // If this is the root node, we don't render
            // a selector, or {}.
            // Otherwise, only output if this ruleset has rules.
            if (isRoot)
            {
                env.Output.AppendMany(rules, env.Compress ? "" : "\n");
            }
            else
            {
                if (rules.Count > 0)
                {
                    paths.AppendCSS(env);

                    env.Output.Append(env.Compress ? "{" : " {\n  ");

                    env.Output.AppendMany(rules, env.Compress ? "" : "\n  ");

                    env.Output.Append(env.Compress ? "}" : "\n}\n");

                }
            }

            env.Output.Append(rulesetOutput);
        }
开发者ID:pipakin,项目名称:dotless,代码行数:69,代码来源:Ruleset.cs

示例2: ToCSS

        protected virtual string ToCSS(Env env, Context context)
        {
            var css = new List<string>(); // The CSS output
            var rules = new List<string>(); // node.Rule instances
            var rulesets = new List<string>(); // node.Ruleset instances
            var paths = new Context(); // Current selectors

            if (!(this is Root))
            {
                paths.AppendSelectors(context, Selectors);
            }

            foreach (var rule in Rules)
            {
                if (rule.IgnoreOutput())
                    continue;

                if(rule is Comment && ((Comment)rule).Silent)
                    continue;

                if (rule is Ruleset)
                {
                    var ruleset = (Ruleset) rule;
                    rulesets.Add(ruleset.ToCSS(env, paths));
                }
                else if (rule is Rule)
                {
                    var r = (rule as Rule);

                    if (!r.Variable)
                        rules.Add(r.ToCSS(env));
                }
                else
                {
                  if (this is Root)
                    rulesets.Add(rule.ToCSS(env));
                  else
                    rules.Add(rule.ToCSS(env));
                }
            }

            var rulesetsStr = rulesets.JoinStrings("");

            // If this is the root node, we don't render
            // a selector, or {}.
            // Otherwise, only output if this ruleset has rules.
            if (this is Root)
                css.Add(rules.JoinStrings(env.Compress ? "" : "\n"));
            else
            {
                if (rules.Count > 0)
                {
                    css.Add(paths.ToCSS(env));

                    css.Add(
                        (env.Compress ? "{" : " {\n  ") +
                        rules.JoinStrings(env.Compress ? "" : "\n  ") +
                        (env.Compress ? "}" : "\n}\n"));
                }
            }
            css.Add(rulesetsStr);

            return css.JoinStrings("");
        }
开发者ID:Tigraine,项目名称:dotless,代码行数:64,代码来源:Ruleset.cs

示例3: GenerateExtenderSelector

        private Context GenerateExtenderSelector(List<IEnumerable<Selector>> selectorStack) {
            if (!selectorStack.Any()) {
                return null;
            }

            var parentContext = GenerateExtenderSelector(selectorStack.Skip(1).ToList());

            var childContext = new Context();
            childContext.AppendSelectors(parentContext, selectorStack.First());
            return childContext;
        }
开发者ID:Ralphvanderneut,项目名称:dotless,代码行数:11,代码来源:Extender.cs

示例4: AppendCSS

        public virtual void AppendCSS(Env env, Context context)
        {
            var rules = new List<StringBuilder>(); // node.Ruleset instances
            int nonCommentRules = 0;
            var paths = new Context(); // Current selectors

            if (!IsRoot)
            {
                if (!env.Compress && env.Debug && Location != null)
                {
                    env.Output.Append(string.Format("/* {0}:L{1} */\n", Location.FileName, Zone.GetLineNumber(Location)));
                }
                paths.AppendSelectors(context, Selectors);
            }

            env.Output.Push();

            foreach (var node in Rules)
            {
                if (node.IgnoreOutput())
                    continue;

                var comment = node as Comment;
                if (comment != null && comment.Silent)
                    continue;

                var ruleset = node as Ruleset;
                if (ruleset != null)
                {
                    ruleset.AppendCSS(env, paths);
                }
                else
                {
                    var rule = node as Rule;

                    if (rule && rule.Variable)
                        continue;

                    if (!IsRoot)
                    {
                        if (!comment)
                            nonCommentRules++;

                        env.Output.Push()
                            .Append(node);
                        rules.Add(env.Output.Pop());
                    }
                    else
                    {
                        env.Output
                            .Append(node);

                        if (!env.Compress)
                        {
                            env.Output
                                .Append("\n");
                        }
                    }
                }
            }

            var rulesetOutput = env.Output.Pop();

            // If this is the root node, we don't render
            // a selector, or {}.
            // Otherwise, only output if this ruleset has rules.
            if (IsRoot)
            {
                env.Output.AppendMany(rules, env.Compress ? "" : "\n");
            }
            else
            {
                if (nonCommentRules > 0)
                {
                    paths.AppendCSS(env);

                    env.Output.Append(env.Compress ? "{" : " {\n  ");

                    env.Output.AppendMany(rules, env.Compress ? "" : "\n  ");

                    if (env.Compress)
                    {
                        env.Output.TrimRight(';');
                    }

                    env.Output.Append(env.Compress ? "}" : "\n}\n");
                }
            }

            env.Output.Append(rulesetOutput);
        }
开发者ID:andytuba,项目名称:dotless,代码行数:91,代码来源:Ruleset.cs

示例5: ToCSS

        protected virtual string ToCSS(Context context)
        {
            var css = new List<string>();                   // The CSS output
              var rules = new List<string>();                 // node.Rule instances
              var rulesets = new List<string>();              // node.Ruleset instances
              var paths = new Context();                      // Current selectors

              if (!Root)
              {
            paths.AppendSelectors(context, Selectors);
              }

              // Evaluate rules and rulesets
              foreach (var rule in Rules)
              {
            if (rule is Ruleset)
            {
              var ruleset = (Ruleset) rule;
              rulesets.Add(ruleset.ToCSS(paths));
            }
            else if (rule is Rule)
            {
              var r = (rule as Rule);

              if (!r.Variable)
            rules.Add(r.ToCSS());
            }
            else if (!rule.IgnoreOutput())
            {
              if (Root)
            rulesets.Add(rule.ToCSS());
              else
            rules.Add(rule.ToCSS());
            }
              }

              var rulesetsStr = rulesets.JoinStrings("");

              // If this is the root node, we don't render
              // a selector, or {}.
              // Otherwise, only output if this ruleset has rules.
              if (Root)
            css.Add(rules.JoinStrings("\n"));
              else
              {
            if (rules.Count > 0)
            {
              css.Add(paths.ToString());

              css.Add(" {\n  " + rules.JoinStrings("\n  ") + "\n}\n");
            }
              }
              css.Add(rulesetsStr);

              return css.JoinStrings("");
        }
开发者ID:JasonCline,项目名称:dotless,代码行数:56,代码来源:Ruleset.cs


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