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

C# Markup.SpecialNode类代码示例

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

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



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

示例1: GetKnownAttributesForSpecialNode

        private List<string> GetKnownAttributesForSpecialNode(SpecialNode node)
        {
            var allKnown = new Dictionary<string, List<string>>
            {
                {"var", new List<string>{"type"}},
                {"def", new List<string>{"type"}},
                {"default", new List<string>{"type"}},
                {"global", new List<string>{"type"}},
                {"viewdata", new List<string>{"default","model"}},
                {"set", new List<string>()},
                {"for", new List<string>{"each"}},
                {"test", new List<string>{"condition", "if", "once"}},
                {"if", new List<string>{"condition", "once"}},
                {"else", new List<string>{"if"}},
                {"elseif", new List<string>{"condition"}},
                {"content", new List<string>{"add","def", "name", "set", "var"}},
                {"use", new List<string>{"assembly", "content", "file", "import", "master", "namespace", "pageBaseType" }},
                {"macro", new List<string>{"name"}},
                {"render", new List<string>{"partial", "section"}},
                {"section", new List<string>{"name"}},
                {"cache", new List<string>{"expires", "key", "signal"}}
            };

            List<string> knownAttributes;

            return allKnown.TryGetValue(node.Element.Name, out knownAttributes)
                ? knownAttributes
                : new List<string>();
        }
开发者ID:rsmolnikov,项目名称:spark,代码行数:29,代码来源:SparkAttributeCompletionSet.cs


示例2: VisitGlobal

        private void VisitGlobal(SpecialNode specialNode)
        {
            var typeAttr = specialNode.Element.Attributes.FirstOrDefault(attr => attr.Name == "type");
            var type = typeAttr != null ? AsCode(typeAttr) : (Snippets)"object";

            foreach (var attr in specialNode.Element.Attributes.Where(a => a != typeAttr))
            {
                AddUnordered(new GlobalVariableChunk { Type = type, Name = attr.Name, Value = AsCode(attr) });
            }
        }
开发者ID:otac0n,项目名称:spark,代码行数:10,代码来源:ChunkBuilderVisitor.cs


示例3: VisitFor

        private void VisitFor(SpecialNode specialNode, SpecialNodeInspector inspector)
        {
            var eachAttr = inspector.TakeAttribute("each");

            var forEachChunk = new ForEachChunk { Code = AsCode(eachAttr), Position = Locate(specialNode.Element) };
            Chunks.Add(forEachChunk);
            using (new Frame(this, forEachChunk.Body))
            {
                foreach (var attr in inspector.Attributes)
                {
                    Chunks.Add(new AssignVariableChunk { Name = attr.Name, Value = AsCode(attr), Position = Locate(attr) });
                }

                Accept(specialNode.Body);
            }
        }
开发者ID:otac0n,项目名称:spark,代码行数:16,代码来源:ChunkBuilderVisitor.cs


示例4: VisitElseIf

        private void VisitElseIf(SpecialNode specialNode, SpecialNodeInspector inspector)
        {
            if (!SatisfyElsePrecondition())
                throw new CompilerException("An 'elseif' may only follow an 'if' or 'elseif'.");

            var conditionAttr = inspector.TakeAttribute("condition");
            var elseIfChunk = new ConditionalChunk { Type = ConditionalType.ElseIf, Condition = AsCode(conditionAttr), Position = Locate(inspector.OriginalNode) };
            Chunks.Add(elseIfChunk);
            using (new Frame(this, elseIfChunk.Body))
                Accept(specialNode.Body);
        }
开发者ID:otac0n,项目名称:spark,代码行数:11,代码来源:ChunkBuilderVisitor.cs


示例5: VisitCache

        private void VisitCache(SpecialNode specialNode, SpecialNodeInspector inspector)
        {
            var keyAttr = inspector.TakeAttribute("key");
            var expiresAttr = inspector.TakeAttribute("expires");
            var signalAttr = inspector.TakeAttribute("signal");

            var chunk = new CacheChunk { Position = Locate(specialNode.Element) };

            if (keyAttr != null)
                chunk.Key = AsCode(keyAttr);
            else
                chunk.Key = "\"\"";

            if (expiresAttr != null)
                chunk.Expires = AsCode(expiresAttr);
            else
                chunk.Expires = "";

            if (signalAttr != null)
                chunk.Signal = AsCode(signalAttr);
            else
                chunk.Signal = "";

            Chunks.Add(chunk);
            using (new Frame(this, chunk.Body))
                Accept(inspector.Body);
        }
开发者ID:otac0n,项目名称:spark,代码行数:27,代码来源:ChunkBuilderVisitor.cs


示例6: Visit

 protected override void Visit(SpecialNode specialNode)
 {
     Add(specialNode);
 }
开发者ID:emiaj,项目名称:spark,代码行数:4,代码来源:SpecialNodeVisitor.cs


示例7: VisitUse

        private void VisitUse(SpecialNode specialNode, SpecialNodeInspector inspector)
        {
            var file = inspector.TakeAttribute("file");
            if (file != null)
            {
                var scope = new ScopeChunk { Position = Locate(inspector.OriginalNode) };
                Chunks.Add(scope);
                using (new Frame(this, scope.Body))
                {
                    foreach (var attr in inspector.Attributes)
                    {
                        Chunks.Add(new LocalVariableChunk { Name = attr.Name, Value = AsCode(attr), Position = Locate(attr) });
                    }

                    var useFileChunk = new RenderPartialChunk { Name = file.Value, Position = Locate(inspector.OriginalNode) };
                    Chunks.Add(useFileChunk);
                    using (new Frame(this, useFileChunk.Body, useFileChunk.Sections))
                    {
                        Accept(inspector.Body);
                    }
                }
            }
            else
            {
                var contentAttr = inspector.TakeAttribute("content");
                var namespaceAttr = inspector.TakeAttribute("namespace");
                var assemblyAttr = inspector.TakeAttribute("assembly");
                var importAttr = inspector.TakeAttribute("import");
                var masterAttr = inspector.TakeAttribute("master");
                var pageBaseTypeAttr = inspector.TakeAttribute("pageBaseType");

                if (contentAttr != null)
                {
                    var useContentChunk = new UseContentChunk { Name = contentAttr.Value, Position = Locate(inspector.OriginalNode) };
                    Chunks.Add(useContentChunk);
                    using (new Frame(this, useContentChunk.Default))
                    {
                        Accept(specialNode.Body);
                    }
                }
                else if (namespaceAttr != null || assemblyAttr != null)
                {
                    if (namespaceAttr != null)
                    {
                        var useNamespaceChunk = new UseNamespaceChunk { Namespace = AsCode(namespaceAttr) };
                        AddUnordered(useNamespaceChunk);
                    }

                    if (assemblyAttr != null)
                    {
                        var useAssemblyChunk = new UseAssemblyChunk { Assembly = assemblyAttr.Value };
                        AddUnordered(useAssemblyChunk);
                    }
                }
                else if (importAttr != null)
                {
                    var useImportChunk = new UseImportChunk { Name = importAttr.Value };
                    AddUnordered(useImportChunk);
                }
                else if (masterAttr != null)
                {
                    var useMasterChunk = new UseMasterChunk { Name = masterAttr.Value };
                    AddUnordered(useMasterChunk);
                }
                else if (pageBaseTypeAttr != null)
                {
                    var usePageBaseTypeChunk = new PageBaseTypeChunk { BaseClass = AsCode(pageBaseTypeAttr) };
                    AddUnordered(usePageBaseTypeChunk);
                }
                else
                {
                    throw new CompilerException("Special node use had no understandable attributes");
                }
            }
        }
开发者ID:otac0n,项目名称:spark,代码行数:75,代码来源:ChunkBuilderVisitor.cs


示例8: VisitRender

        private void VisitRender(SpecialNode node, SpecialNodeInspector inspector)
        {
            var partial = inspector.TakeAttribute("partial");

            if (partial != null)
            {
                var scope = new ScopeChunk { Position = Locate(inspector.OriginalNode) };
                Chunks.Add(scope);
                using (new Frame(this, scope.Body))
                {
                    foreach (var attr in inspector.Attributes)
                    {
                        Chunks.Add(new LocalVariableChunk { Name = attr.Name, Value = AsCode(attr), Position = Locate(attr) });
                    }

                    var renderPartial = new RenderPartialChunk { Name = partial.Value, Position = Locate(inspector.OriginalNode) };
                    Chunks.Add(renderPartial);

                    using (new Frame(this, renderPartial.Body, renderPartial.Sections))
                    {
                        Accept(inspector.Body);
                    }
                }
            }
            else
            {
                var sectionAttr = inspector.TakeAttribute("section");

                string sectionName = null;
                if (sectionAttr != null)
                    sectionName = sectionAttr.Value;

                var scope = new ScopeChunk { Position = Locate(inspector.OriginalNode) };
                Chunks.Add(scope);
                using (new Frame(this, scope.Body))
                {
                    foreach (var attr in inspector.Attributes)
                    {
                        Chunks.Add(new LocalVariableChunk { Name = attr.Name, Value = AsCode(attr), Position = Locate(attr) });
                    }

                    var render = new RenderSectionChunk { Name = sectionName };
                    Chunks.Add(render);
                    using (new Frame(this, render.Default))
                    {
                        Accept(inspector.Body);
                    }
                }
            }
        }
开发者ID:otac0n,项目名称:spark,代码行数:50,代码来源:ChunkBuilderVisitor.cs


示例9: Visit

 protected abstract void Visit(SpecialNode specialNode);
开发者ID:Eilon,项目名称:spark,代码行数:1,代码来源:AbstractNodeVisitor.cs


示例10: Visit

        protected override void Visit(SpecialNode node)
        {
            bool detachFromParent = false;
            if (NameUtility.IsMatch("else", Context.Namespaces, node.Element.Name, node.Element.Namespace) &&
                node.Element.IsEmptyElement &&
                _frame.TestParentNodes != null)
            {
                detachFromParent = true;
            }

            if (detachFromParent)
            {
                var reconstructed = new SpecialNode(node.Element);
                _frame.TestParentNodes.Add(reconstructed);
                _frame.Nodes = reconstructed.Body;
            }
            else
            {
                var reconstructed = new SpecialNode(node.Element);
                Nodes.Add(reconstructed);

                var parentNodes = _frame.Nodes;

                PushFrame();

                _frame.Nodes = reconstructed.Body;
                if (NameUtility.IsMatch("if", Context.Namespaces, node.Element.Name, node.Element.Namespace) ||
                    NameUtility.IsMatch("test", Context.Namespaces, node.Element.Name, node.Element.Namespace))
                {
                    _frame.TestParentNodes = parentNodes;
                }

                Accept(node.Body);

                PopFrame();
            }
        }
开发者ID:Eilon,项目名称:spark,代码行数:37,代码来源:TestElseElementVisitor.cs


示例11: SpecialNodeInspector

 public SpecialNodeInspector(SpecialNode node)
 {
     _node = node;
     Attributes = new List<AttributeNode>(node.Element.Attributes);
 }
开发者ID:ronniebarker,项目名称:spark,代码行数:5,代码来源:SpecialNodeInspector.cs


示例12: VisitIgnore

 private void VisitIgnore(SpecialNode specialNode, SpecialNodeInspector inspector)
 {
     Accept(specialNode.Body);
 }
开发者ID:emiaj,项目名称:spark,代码行数:4,代码来源:ChunkBuilderVisitor.cs


示例13: PushSpecial

 private void PushSpecial(ElementNode element)
 {
     SpecialNode special = new SpecialNode(element) { OriginalNode = element };
     Nodes.Add(special);
     _stack.Push(Nodes);
     _nodes = special.Body;
 }
开发者ID:otac0n,项目名称:spark,代码行数:7,代码来源:SpecialNodeVisitor.cs


示例14: Visit

 protected override void Visit(SpecialNode specialNode)
 {
     throw new System.NotImplementedException();
 }
开发者ID:otac0n,项目名称:spark,代码行数:4,代码来源:SpecialNodeVisitor.cs


示例15: VisitIf

        private void VisitIf(SpecialNode specialNode, SpecialNodeInspector inspector)
        {
            var conditionAttr = inspector.TakeAttribute("condition") ?? inspector.TakeAttribute("if");

            var onceAttr = inspector.TakeAttribute("once");

            if (conditionAttr == null && onceAttr == null)
            {
                throw new CompilerException("Element must contain an if, condition, or once attribute");
            }

            Frame ifFrame = null;
            if (conditionAttr != null)
            {
                var ifChunk = new ConditionalChunk { Type = ConditionalType.If, Condition = AsCode(conditionAttr), Position = Locate(inspector.OriginalNode) };
                Chunks.Add(ifChunk);
                ifFrame = new Frame(this, ifChunk.Body);
            }

            Frame onceFrame = null;
            if (onceAttr != null)
            {
                var onceChunk = new ConditionalChunk { Type = ConditionalType.Once, Condition = onceAttr.AsCodeInverted(), Position = Locate(inspector.OriginalNode) };
                Chunks.Add(onceChunk);
                onceFrame = new Frame(this, onceChunk.Body);
            }

            Accept(specialNode.Body);

            if (onceFrame != null)
                onceFrame.Dispose();

            if (ifFrame != null)
                ifFrame.Dispose();
        }
开发者ID:otac0n,项目名称:spark,代码行数:35,代码来源:ChunkBuilderVisitor.cs


示例16: VisitMarkdown

        private void VisitMarkdown(SpecialNode specialNode, SpecialNodeInspector inspector)
        {
            var markdownChunk = new MarkdownChunk();

            Chunks.Add(markdownChunk);
            using (new Frame(this, markdownChunk.Body))
            {
                Accept(inspector.Body);
            }
        }
开发者ID:otac0n,项目名称:spark,代码行数:10,代码来源:ChunkBuilderVisitor.cs


示例17: VisitNode

        public void VisitNode(INodeVisitor visitor, IList<Node> body, IList<Chunk> chunks)
        {
            var registerTarget = string.Format(
                @"RegisterTarget(""{0}"", ""{1}"", ""{2}"", __target_{3});",
                _idAttribute.Value,
                _classAttribute != null ? _classAttribute.Value : "",
                _descriptionAttribute != null ? _descriptionAttribute.Value : "",
                _targetExtensionCount);

            if (_targetAttribute != null)
            {
                registerTarget +=
                    Environment.NewLine +
                    string.Format(
                        @"RegisterTarget(""{0}"", ""{1}"", null, null);",
                        _targetAttribute.Value,
                        _idAttribute.Value);
            }

            var beginLambda = string.Format(
                @"__target_{0} = () => {{",
                _targetExtensionCount);
            const string endLambda = "};";

            var startingTarget = string.Format(
                @"StartingTarget(""{0}"");",
                _idAttribute.Value);

            var nameAttribute = new AttributeNode("name", _idAttribute.QuotChar, _idAttribute.Nodes) { OriginalNode = _idAttribute };

            var macroAttributes = _targetElement.Attributes
                .Where(x => x != _idAttribute && x != _classAttribute && x != _descriptionAttribute)
                .Concat(new[] { nameAttribute })
                .ToList();
            var macroElement = new SpecialNode(new ElementNode("macro", macroAttributes, false));

            var onceAttribute = new AttributeNode("once", _idAttribute.QuotChar, _idAttribute.Nodes);
            var testElement = new SpecialNode(new ElementNode("test", new[] { onceAttribute }, false));

            macroElement.Body.Add(testElement);
            testElement.Body = body;
            testElement.Body.Insert(0, new StatementNode(startingTarget));

            visitor.Accept(new StatementNode(beginLambda));
            visitor.Accept(testElement);
            visitor.Accept(new StatementNode(endLambda));
            visitor.Accept(new StatementNode(registerTarget));
        }
开发者ID:Eilon,项目名称:sake,代码行数:48,代码来源:TargetExtension.cs


示例18: VisitSection

        private void VisitSection(SpecialNode node, SpecialNodeInspector inspector)
        {
            if (SectionChunks == null)
                throw new CompilerException("Section cannot be used at this location", Locate(node.Element));

            var name = inspector.TakeAttribute("name");
            if (name == null)
                throw new CompilerException("Section element must have a name attribute", Locate(node.Element));

            IList<Chunk> sectionChunks;
            if (!SectionChunks.TryGetValue(name.Value, out sectionChunks))
            {
                sectionChunks = new List<Chunk>();
                SectionChunks.Add(name.Value, sectionChunks);
            }

            var scope = new ScopeChunk { Position = Locate(inspector.OriginalNode) };
            sectionChunks.Add(scope);
            using (new Frame(this, scope.Body))
            {
                foreach (var attr in inspector.Attributes)
                {
                    Chunks.Add(new LocalVariableChunk { Name = attr.Name, Value = AsCode(attr), Position = Locate(attr) });
                }

                Accept(inspector.Body);
            }
        }
开发者ID:otac0n,项目名称:spark,代码行数:28,代码来源:ChunkBuilderVisitor.cs


示例19: Visit

        protected override void Visit(SpecialNode specialNode)
        {
            string nqName = NameUtility.GetName(specialNode.Element.Name);
            if (!SpecialNodeMap.ContainsKey(nqName))
            {
                throw new CompilerException(string.Format("Unknown special node {0}", specialNode.Element.Name));
            }

            var action = SpecialNodeMap[nqName];
            action(specialNode, new SpecialNodeInspector(specialNode));
        }
开发者ID:otac0n,项目名称:spark,代码行数:11,代码来源:ChunkBuilderVisitor.cs


示例20: VisitVar

        private void VisitVar(SpecialNode specialNode, SpecialNodeInspector inspector)
        {
            Frame frame = null;
            if (!specialNode.Element.IsEmptyElement)
            {
                var scope = new ScopeChunk { Position = Locate(specialNode.Element) };
                Chunks.Add(scope);
                frame = new Frame(this, scope.Body);
            }

            var typeAttr = inspector.TakeAttribute("type");
            var type = typeAttr != null ? AsCode(typeAttr) : (Snippets)"var";

            foreach (var attr in inspector.Attributes)
            {
                Chunks.Add(new LocalVariableChunk { Type = type, Name = attr.Name, Value = AsCode(attr), Position = Locate(attr) });
            }

            Accept(specialNode.Body);

            if (frame != null)
                frame.Dispose();
        }
开发者ID:otac0n,项目名称:spark,代码行数:23,代码来源:ChunkBuilderVisitor.cs



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C# SparkleLib.SparkleGit类代码示例发布时间:2022-05-26
下一篇:
C# Markup.ElementNode类代码示例发布时间:2022-05-26
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

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

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

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