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


C# Element.AddChild方法代码示例

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


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

示例1: WriteParams

        public static Element WriteParams(ArrayList Params)
        {
            if (Params != null && Params.Count > 0)
            {
                Element elParams = new Element("params");

                for (int i = 0; i < Params.Count; i++)
                {
                    Element param = new Element("param");
                    WriteValue(Params[i], param);
                    elParams.AddChild(param);
                }
                return elParams;
            }
            return null;
        }
开发者ID:don59,项目名称:agsXmpp,代码行数:16,代码来源:RpcHelper.cs

示例2: WriteCall

        /// <summary>
        ///   Write the functions call with params to this Element
        /// </summary>
        /// <param name="name"> </param>
        /// <param name="Params"> </param>
        public void WriteCall(string name, ArrayList Params)
        {
            MethodName = name;

            if (Params != null && Params.Count > 0)
            {
                // remote this tag if exists, in case this function gets
                // calles multiple times by some guys
                RemoveTag("params");
                var elParams = new Element("params");

                for (int i = 0; i < Params.Count; i++)
                {
                    var param = new Element("param");
                    WriteValue(Params[i], param);
                    elParams.AddChild(param);
                }
                AddChild(elParams);
            }
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:25,代码来源:MethodCall.cs

示例3: WriteValue

        /// <summary>
        ///   Writes a single value to a call
        /// </summary>
        /// <param name="param"> </param>
        /// <param name="parent"> </param>
        private void WriteValue(object param, Element parent)
        {
            var value = new Element("value");

            if (param is String)
            {
                value.AddChild(new Element("string", param as string));
            }
            else if (param is Int32)
            {
                value.AddChild(new Element("i4", ((Int32) param).ToString()));
            }
            else if (param is Double)
            {
                var numberInfo = new NumberFormatInfo();
                numberInfo.NumberDecimalSeparator = ".";
                //numberInfo.NumberGroupSeparator = ",";
                value.AddChild(new Element("double", ((Double) param).ToString(numberInfo)));
            }
            else if (param is Boolean)
            {
                value.AddChild(new Element("boolean", ((bool) param) ? "1" : "0"));
            }
                // XML-RPC dates are formatted in iso8601 standard, same as xmpp,
            else if (param is DateTime)
            {
                value.AddChild(new Element("dateTime.iso8601", Time.ISO_8601Date((DateTime) param)));
            }
                // byte arrays must be encoded in Base64 encoding
            else if (param is byte[])
            {
                var b = (byte[]) param;
                value.AddChild(new Element("base64", Convert.ToBase64String(b, 0, b.Length)));
            }
                // Arraylist maps to an XML-RPC array
            else if (param is ArrayList)
            {
                //<array>  
                //    <data>
                //        <value>  <string>one</string>  </value>
                //        <value>  <string>two</string>  </value>
                //        <value>  <string>three</string></value>  
                //    </data> 
                //</array>
                var array = new Element("array");
                var data = new Element("data");

                var list = param as ArrayList;

                for (int i = 0; i < list.Count; i++)
                {
                    WriteValue(list[i], data);
                }

                array.AddChild(data);
                value.AddChild(array);
            }
                // java.util.Hashtable maps to an XML-RPC struct
            else if (param is Hashtable)
            {
                var elStruct = new Element("struct");

                var ht = (Hashtable) param;
                IEnumerator myEnumerator = ht.Keys.GetEnumerator();
                while (myEnumerator.MoveNext())
                {
                    var member = new Element("member");
                    object key = myEnumerator.Current;

                    member.AddChild(new Element("name", key.ToString()));
                    WriteValue(ht[key], member);

                    elStruct.AddChild(member);
                }

                value.AddChild(elStruct);
            }
            else
            {
                // Unknown Type
            }
            parent.AddChild(value);
        }
开发者ID:Inzaghi2012,项目名称:teamlab.v7.5,代码行数:88,代码来源:MethodCall.cs

示例4: Send

        public override void Send(Element e)
        {
            // this is a hack to not send the xmlns="jabber:component:accept" with all packets
            Element dummyEl = new Element("a");
            dummyEl.Namespace = Uri.ACCEPT;

            dummyEl.AddChild(e);
            string toSend = dummyEl.ToString();

            Send(toSend.Substring(35, toSend.Length - 35 - 4));
        }
开发者ID:SightstoneOfficial,项目名称:agsxmpp,代码行数:11,代码来源:XmppComponentConnection.cs

示例5: Message2

        private void Message2()
        {
            // transient message (will not be stored offline if the server support AMP)

            /*
            <message to='[email protected]'
                     from='[email protected]/elsinore'
                     type='chat'
                     id='chatty1'>
              <body>Who&apos;s there?</body>
              <amp xmlns='http://jabber.org/protocol/amp'>
                <rule action='drop' condition='deliver' value='stored'/>
              </amp>
            </message>
            */

            agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();
            msg.To = new Jid("[email protected]");
            msg.From = new Jid("[email protected]/elsinore");
            msg.Type = MessageType.chat;
            msg.Id = "chatty1";

            msg.Body = "Who&apos;s there?";

            Element amp = new Element();
            amp.TagName     = "amp";
            amp.Namespace   = "http://jabber.org/protocol/amp";

            Element rule = new Element();
            rule.TagName    = "rule";
            rule.Namespace  = "http://jabber.org/protocol/amp";
            rule.SetAttribute("action", "drop");
            rule.SetAttribute("condition", "deliver");
            rule.SetAttribute("value", "stored");

            amp.AddChild(rule);
            msg.AddChild(amp);

            Program.Print(msg);
        }
开发者ID:phiree,项目名称:dzdocs,代码行数:40,代码来源:Message.cs

示例6: ToElement

        public static IElement ToElement(this HtmlNode self, INode parent)
        {
            if (self == null)
                throw new ArgumentNullException("self");
            if (parent == null)
                throw new ArgumentNullException("parent");

            var name = self.ToQualifiedName();
            var element = new Element(parent, name);

            foreach (var attribute in self.ToAttributes(element))
                element.AddAttribute(attribute);

            foreach (var child in self.ToChildren(element))
                element.AddChild(child);

            var customElement = GetCustomElement(element, parent, name);
            if (customElement != null)
            {
                foreach (var attribute in self.ToAttributes(customElement))
                    customElement.AddAttribute(attribute);

                foreach (var child in self.ToChildren(customElement))
                    customElement.AddChild(child);

                return customElement;
            }

            return element;
        }
开发者ID:bossaia,项目名称:alexandrialibrary,代码行数:30,代码来源:HtmlNodeExtensions.cs

示例7: Send

        public override void Send(Element e)
        {
            if (!(ClientSocket is BoshClientSocket))
            {
                // this is a hack to not send the xmlns="jabber:client" with all packets
                Element dummyEl = new Element("a");
                dummyEl.Namespace = Uri.CLIENT;

                dummyEl.AddChild(e);
                string toSend = dummyEl.ToString();

                Send(toSend.Substring(25, toSend.Length - 25 - 4));
            }
            else
                base.Send(e);
        }
开发者ID:jptoto,项目名称:argsxmpp,代码行数:16,代码来源:XmppClientConnection.cs

示例8: CreateInstructionsMenu

        private void CreateInstructionsMenu(Element menu)
        {
            TextWidget text = new TextWidget();
            text.Font = Fonts.Instance.TanksAltFont;
            text.Location = new Vector(BattleGame.ResolutionX / 2, 350);
            text.Size = new Vector(300, 280);

            text.Text = "Arrow keys - movement,\nSpace - fire,\nP - pause,\nEscape - main menu";
            text.Enabled = false;

            menu.AddChild(text);
        }
开发者ID:rinat,项目名称:battle,代码行数:12,代码来源:MainMenuScene.cs

示例9: CreateAboutMenuContent

        private void CreateAboutMenuContent(Element menu)
        {
            TextWidget text = new TextWidget();
            text.Font = Fonts.Instance.TanksAltFont;
            text.Location = new Vector(BattleGame.ResolutionX / 2, 350);
            text.Size = new Vector(600, 280);

            {
                var gameInfo = "Simple Tanks game (based on Vortex2D.NET).\n";
                var courseInfo = "Course - The Perspective Software\n";
                var lecturerInfo = "Lecturer - Druzhinin U.V.\n";
                var studentsInfo = "Students - Zhdanov A.V., Shaihutdinov R.G.\n";

                text.Text = gameInfo + courseInfo + lecturerInfo + studentsInfo;
                text.Enabled = false;
            }

            menu.AddChild(text);
        }
开发者ID:rinat,项目名称:battle,代码行数:19,代码来源:MainMenuScene.cs

示例10: AddChild

        private void AddChild(Element parent)
        {
            TypeBrowser browser = TypeBrowser.Create(parent.GetType());
            Element child = this.GetElement();
            if (child is UnknownElement)
            {
                PropertyInfo property = browser.FindElement(this.GetXmlComponent());
                if (property != null)
                {
                    AssignValue(parent, property, child.InnerText);

                    // We're not going to add it to the parent, which has the potential to
                    // lose any attributes/child elements assigned to the unknown, but this
                    // is the behaviour of the C++ version.
                    return;
                }
            }
            else if (parent.AddChild(child))
            {
                this.OnElementAdded(child); // Call it here after it's Parent has been set
                return; // Not an orphan
            }
            else // Lets try an Element as a proprty?
            {
                this.OnElementAdded(child); // Will be either added as a Property or Orphan

                // Search for a property that we can assign to
                Type type = child.GetType();
                foreach (var property in browser.Elements)
                {
                    if (property.Item1.PropertyType.IsAssignableFrom(type))
                    {
                        property.Item1.SetValue(parent, child, null);
                        return;
                    }
                }
            }

            parent.AddOrphan(child); // Save for later serialization
        }
开发者ID:CraigElder,项目名称:MissionPlanner,代码行数:40,代码来源:Parser.cs

示例11: AddElement

 private void AddElement(Element element, Element parent)
 {
     if (element != null)
     {
         AddElementToMap(element);
         if (parent != null)
         {
             parent.AddChild(element);
         }
     }
 }
开发者ID:0anion0,项目名称:IBN,代码行数:11,代码来源:GanttView.cs


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