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


C# Element.Add方法代码示例

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


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

示例1: CanAddSubElements

 public void CanAddSubElements()
 {
     var e2 = new Element("E2");
     var element = new Element("El");
     element.Add(e2);
     Assert.That(element.Elements.Contains(e2));
 }
开发者ID:jongalloway,项目名称:nLess,代码行数:7,代码来源:ElementFixtures.cs

示例2: CanRetrieveNearestElement

        public void CanRetrieveNearestElement()
        {
            var root = new Element();
            var e2 = new Element("E2", ">");
            var e3 = new Element("#yahoo");
            var e1 = new Element(".hello");
            var e1_sibling = new Element(".goodbye");
            var e1_siblingb = new Element(".helloAgain");
            root.Add(e1);
            root.Add(e1_sibling);
            root.Add(e1_siblingb);
            root.Add(new Variable("@RootVariable", new Color(1, 1, 1)));
            e1.Add(e2);
            e2.Add(e3);
            e2.Add(new Variable("@Variable", new Color(1, 1, 1)));
            e2.Add(new Variable("@NumVariable", new Number(10)));
            var nearestEl = e3.Nearest("@Variable");
            Assert.AreEqual(nearestEl.ToString(), "@Variable");

            //TODO: Remove this nonsense it isnt a test its just to see ToCSS output
            var nodes = new List<INode>
                            {
                                new Variable("@Variable", new Color(1, 1, 1)),
                                new Operator("+"),
                                new Number(2)
                            };
            e1.Add(new Property("color", nodes));
            e1_sibling.Add(new Property("color", nodes));
            e1_siblingb.Add(new Property("color", nodes));
            var nodesb = new List<INode>
                            {
                                new Number("px", 4),
                                new Operator("*"),
                                new Variable("@NumVariable")
                            };

            e2.Add(new Property("padding", nodesb));

            var nodesc = new List<INode>
                            {
                                new Variable("@RootVariable", new Color(1, 1, 1)),
                                new Operator("+"),
                                new Variable("@Variable", new Color(1, 1, 1))
                            };
            e3.Add(new Property("background-color", nodesc));
            Console.WriteLine(root.Group().ToCss());
        }
开发者ID:erikvanbrakel,项目名称:nLess,代码行数:47,代码来源:ElementFixtures.cs

示例3: StandardSelectors

 /// <summary>
 /// standard_ruleset: ws selectors [{] ws primary ws [}] ws;
 /// </summary>
 /// <param name="element"></param>
 /// <param name="els"></param>
 /// <returns></returns>
 private static IList<Element> StandardSelectors(Element element, IEnumerable<Element> els)
 {
     foreach (var el in els){
         element.Add(el);
         element = element.Last;
     }
     return new List<Element> { element};
 }
开发者ID:erikvanbrakel,项目名称:nLess,代码行数:14,代码来源:TreeBuilder.cs

示例4: CanRetrieveElementPath

 public void CanRetrieveElementPath()
 {
     var e2 = new Element("E2");
     var e3 = new Element("E3");
     var element = new Element("El");
     element.Add(e2);
     e2.Add(e3);
     Assert.That(e3.Path().Contains(element));
 }
开发者ID:jongalloway,项目名称:nLess,代码行数:9,代码来源:ElementFixtures.cs

示例5: AddDeferredAttribute

 /// <summary>
 /// Creates a new attribute on an <see cref="Element"/>. This method is intended for <see cref="ICodec"/> implementers and should not be directly called from any other code.
 /// </summary>
 /// <param name="elem">The Element to add to.</param>
 /// <param name="key">The name of the attribute. Must be unique on the Element.</param>
 /// <param name="defer_offset">The location in the encoded DMX stream at which this Attribute's value can be found.</param>
 public static void AddDeferredAttribute(Element elem, string key, long offset)
 {
     if (offset <= 0) throw new ArgumentOutOfRangeException("offset", "Address must be greater than 0.");
     elem.Add(key, offset);
 }
开发者ID:Artfunkel,项目名称:Datamodel.NET,代码行数:11,代码来源:ICodec.cs

示例6: StandardSelectors

 /// <summary>
 /// standard_ruleset: ws selectors [{] ws primary ws [}] ws;
 /// </summary>
 /// <param name="element"></param>
 /// <param name="els"></param>
 /// <returns></returns>
 private static IEnumerable<Element> StandardSelectors(Element element, IEnumerable<Element> els)
 {
     foreach (var el in els)
     {
         element.Add(el);
         element = element.Last;
     }
     yield return element;
 }
开发者ID:jongalloway,项目名称:nLess,代码行数:15,代码来源:TreeBuilder.cs

示例7: Insert

        private IEnumerable<INode> Insert(PegNode node, Element element)
        {
            node = (node.child_ ?? node);
            var path = (node).GetAsString(Src)
                .Replace("\"", "").Replace("'", "");

            if (HttpContext.Current != null){
                path = HttpContext.Current.Server.MapPath(path);
            }

            if (File.Exists(path)){
                var text = File.ReadAllText(path);
                element.Add(new Insert(text));
            }
            return new List<INode>();
        }
开发者ID:jongalloway,项目名称:nLess,代码行数:16,代码来源:TreeBuilder.cs

示例8: Declaration

        /// <summary>
        /// declaration:  standard_declaration / catchall_declaration ;
        /// </summary>
        /// <param name="node"></param>
        /// <param name="element"></param>
        private void Declaration(PegNode node, Element element)
        {
            var name = node.GetAsString(Src).Replace(" ", "");
            var nextNode = node.next_;

            if(nextNode == null){
                // TODO: emit warning: empty declaration //
                return;
            }
            if (nextNode.ToEnLess() == EnLess.comment)
                nextNode = nextNode.next_;

            var values = Expressions(nextNode, element);
            var property = name.StartsWith("@") ? new Variable(name, values) : new Property(name, values);
            element.Add(property);
        }
开发者ID:jongalloway,项目名称:nLess,代码行数:21,代码来源:TreeBuilder.cs

示例9: Process

 protected virtual Generic.IEnumerator<Node> Process(Element element)
 {
     Element result = new Element(element.Name, this.Process(element.Attributes.GetEnumerator())) { Region = element.Region };
     foreach (Node node in element)
         this.Process(node).Apply(n =>
         {
             if (n.NotNull())
                 result.Add(n);
         });
     yield return result;
 }
开发者ID:imintsystems,项目名称:Kean,代码行数:11,代码来源:Processor.cs

示例10: Decode

        public Datamodel Decode(int encoding_version, string format, int format_version, Stream stream, DeferredMode defer_mode)
        {
            stream.Seek(0, SeekOrigin.Begin);
            while (true)
            {
                var b = stream.ReadByte();
                if (b == 0) break;
            }
            var dm = new Datamodel(format, format_version);

            EncodingVersion = encoding_version;
            Reader = new BinaryReader(stream, Datamodel.TextEncoding);

            if (EncodingVersion >= 9)
            {
                // Read prefix elements
                foreach (int prefix_elem in Enumerable.Range(0, Reader.ReadInt32()))
                {
                    foreach (int attr_index in Enumerable.Range(0, Reader.ReadInt32()))
                    {
                        var name = ReadString_Raw();
                        var value = DecodeAttribute(dm);
                        if (prefix_elem == 0) // skip subsequent elements...are they considered "old versions"?
                            dm.PrefixAttributes[name] = value;
                    }
                }
            }

            StringDict = new StringDictionary(this, Reader);
            var num_elements = Reader.ReadInt32();

            // read index
            foreach (var i in Enumerable.Range(0, num_elements))
            {
                var type = StringDict.ReadString();
                var name = EncodingVersion >= 4 ? StringDict.ReadString() : ReadString_Raw();
                var id_bits = Reader.ReadBytes(16);
                var id = new Guid(BitConverter.IsLittleEndian ? id_bits : id_bits.Reverse().ToArray());

                var elem = new Element(dm, name, id, type);
            }

            // read attributes (or not, if we're deferred)
            foreach (var elem in dm.AllElements.ToArray())
            {
                System.Diagnostics.Debug.Assert(!elem.Stub);

                var num_attrs = Reader.ReadInt32();

                foreach (var i in Enumerable.Range(0, num_attrs))
                {
                    var name = StringDict.ReadString();

                    if (defer_mode == DeferredMode.Automatic)
                    {
                        CodecUtilities.AddDeferredAttribute(elem, name, Reader.BaseStream.Position);
                        SkipAttribte();
                    }
                    else
                    {
                        elem.Add(name, DecodeAttribute(dm));
                    }
                }
            }
            return dm;
        }
开发者ID:Artfunkel,项目名称:Datamodel.NET,代码行数:66,代码来源:Binary.cs

示例11: Declaration

        /// <summary>
        /// declaration:  standard_declaration / catchall_declaration ;
        /// </summary>
        /// <param name="node"></param>
        /// <param name="element"></param>
        private void Declaration(PegNode node, Element element)
        {
            if (node.id_.ToEnLess() == EnLess.standard_declaration)
            {
                node = node.child_;
                var name = node.GetAsString(Src).Replace(" ", "");

                if (name.Substring(0, 1) == "@")
                {
                    var property = new Variable(name, Expressions(node.next_, element));
                    element.Add(property);
                }
                else
                {
                    var property = new Property(name, Expressions(node.next_, element));
                    element.Add(property);
                }
            }
            else if (node.id_.ToEnLess() == EnLess.catchall_declaration)
            {
            /*                node = node.child_;
                var name = node.GetAsString(Src).Replace(" ", "");
                element.Add(new Property(name));*/

                //TODO: Should I be doing something here?
            }
        }
开发者ID:erikvanbrakel,项目名称:nLess,代码行数:32,代码来源:TreeBuilder.cs


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