當前位置: 首頁>>代碼示例>>C#>>正文


C# XElement.SetElementValue方法代碼示例

本文整理匯總了C#中System.Xml.Linq.XElement.SetElementValue方法的典型用法代碼示例。如果您正苦於以下問題:C# XElement.SetElementValue方法的具體用法?C# XElement.SetElementValue怎麽用?C# XElement.SetElementValue使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Xml.Linq.XElement的用法示例。


在下文中一共展示了XElement.SetElementValue方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: BuildCommonDataNodeInfo

 /// <summary>
 /// Builds the common data node info.
 /// </summary>
 /// <param name="commonDataNode">The common data node.</param>
 protected virtual void BuildCommonDataNodeInfo(XElement commonDataNode)
 {
     commonDataNode.SetElementValue("TaskCompletedMessage", LocalizedObjectHelper.GetLocalizedStringFrom("TaskCompletedMessageFormatter"));
     commonDataNode.SetElementValue("TaskCompleteWithZeroMessage", LocalizedObjectHelper.GetLocalizedStringFrom("TaskCompleteWithZeroMessage"));
     commonDataNode.SetElementValue("DefaultCurrency", AppSetting.Instance.DefaultCurrency);
     commonDataNode.SetElementValue("AppName", AppSetting.Instance.AppName.IsNullOrEmpty() ? "ACCOUNTBOOK" : AppSetting.Instance.AppName);
     commonDataNode.SetElementValue("Weekends", AppSetting.Weekends.ToStringLine<string>(","));
 }
開發者ID:RukaiYu,項目名稱:TinyMoneyManager.WP8,代碼行數:12,代碼來源:SchedulePlanningManager.cs

示例2: addDatabase

 public static void addDatabase(GeispDatabase db)
 {
     XElement asocs = doc;
     XElement xmlDb = new XElement("asoc");
     xmlDb.SetAttributeValue("name", db.name);
     xmlDb.SetElementValue("name", db.name);
     xmlDb.SetElementValue("mdb", db.mdb);
     xmlDb.SetElementValue("excel", db.excel);
     xmlDb.SetElementValue("mdb2", db.mdb2);
     asocs.Add(xmlDb);
     doc.Save(directory + "GEISP\\GEISP.xml");
 }
開發者ID:Rotariu-Stefan,項目名稱:BSS,代碼行數:12,代碼來源:GeispUtils.cs

示例3: ObjToXElement

        public static XElement ObjToXElement(PObject obj)
        {
            XElement x = new XElement("obj");

            XElement xAttrs = new XElement("attrs");
            foreach (string attr in obj._attrs.Keys)
            {
                xAttrs.SetElementValue(attr, obj._attrs[attr]);
            }
            x.Add(xAttrs);

            XElement xColls = new XElement("colls");
            x.Add(xColls);
            foreach (PCollection coll in obj._collections.Values)
            {
                XElement xColl = new XElement("coll");
                xColl.SetAttributeValue("name", coll.Name);
                xColls.Add(xColl);
                int cnt = coll.Count;
                for (int i = 0; i < cnt; i++)
                {
                    XElement xi = ObjToXElement(coll._items[i]);
                    xi.SetAttributeValue("num", i);
                    xColl.Add(xi);
                }
            }
            return x;
        }
開發者ID:kindprojects,項目名稱:workstation,代碼行數:28,代碼來源:PObject.cs

示例4: SaveUserData

 internal void SaveUserData(XElement node)
 {
     node.SetElementValue("ShowMessages", this.buttonMessages.Checked);
     node.SetElementValue("ShowWarnings", this.buttonWarnings.Checked);
     node.SetElementValue("ShowErrors", this.buttonErrors.Checked);
     node.SetElementValue("ShowCore", this.buttonCore.Checked);
     node.SetElementValue("ShowEditor", this.buttonEditor.Checked);
     node.SetElementValue("ShowGame", this.buttonGame.Checked);
     node.SetElementValue("AutoClear", this.checkAutoClear.Checked);
     node.SetElementValue("PauseOnError", this.buttonPauseOnError.Checked);
 }
開發者ID:ChrisLakeZA,項目名稱:duality,代碼行數:11,代碼來源:LogView.cs

示例5: AddNode

    protected void AddNode()
    {
        XElement parentXElement = null;
        XElement refXElement = null;
        XElement newXElement = null;
        int nodescount = CountNodes();

        parentXElement = xmlDoc.XPathSelectElement("customers");

        //newXElement.SetAttributeValue("url", parent_url_txt.Text);
        //newXElement.SetAttributeValue("src", "");

        if (nodescount == 0)
        {
            //refXElement = xmlDoc.XPathSelectElement("customers/customer[@id = '1']");
            //refXElement.SetElementValue("name",NameTextBox.Text);
            //refXElement.SetElementValue("designation", DesignationTextBox.Text);

            newXElement = new XElement("customer");
            newXElement.SetAttributeValue("id", (nodescount + 1).ToString());
            newXElement.SetElementValue("name", NameTextBox.Text);
            newXElement.SetElementValue("phone", ContactTextBox.Text);
            newXElement.SetElementValue("country", country.SelectedItem.Text);
            newXElement.SetElementValue("email", MailTextBox.Text);
            newXElement.SetElementValue("subject", SubjectTextBox.Text);
            parentXElement.AddFirst(newXElement);
        }
        else if (nodescount > 0)
        {
            newXElement = new XElement("customer");
            newXElement.SetAttributeValue("id", (nodescount + 1).ToString());
            newXElement.SetElementValue("name", NameTextBox.Text);
            newXElement.SetElementValue("phone", ContactTextBox.Text);
            newXElement.SetElementValue("country", country.SelectedItem.Text);
            newXElement.SetElementValue("email", MailTextBox.Text);
            newXElement.SetElementValue("subject", SubjectTextBox.Text);
            parentXElement.LastNode.AddAfterSelf(newXElement);
        }

        xmlDoc.Save(UpPath);
        string message = "New parent menu added successfully";
        Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "customalert", "<script type='text/javascript'>customalert('" + message + "')</script>");
    }
開發者ID:kkkamalakannan,項目名稱:test1,代碼行數:43,代碼來源:CloudRegistration.aspx.cs

示例6: CreateXElementElementaryDataTypes

        public void CreateXElementElementaryDataTypes()
        {
            var person = new Person()
            {
                Name = "Peter",
                Birthday = new DateTime(2015, 7, 7),
                Height = 180,
                Weight = 80
            };

            var expectedElement = new XElement("Person");
            expectedElement.SetElementValue("Name", "Peter");
            expectedElement.SetElementValue("Birthday", "2015-07-07T00:00:00");
            expectedElement.SetElementValue("Weight", "80");
            expectedElement.SetElementValue("Height", "180");

            var dataStore = new PersonDataStore();
            var xElement = dataStore.CreateXElement(person);

            var guid = xElement.GetGuid();
            expectedElement.SetAttributeValue("ref", guid);

            Assert.AreEqual(expectedElement.Value, xElement.Value);
        }
開發者ID:Blackjack92,項目名稱:PersistenceFramework,代碼行數:24,代碼來源:DataStoreObjectTests.cs

示例7: Main

        static void Main(string[] args)
        {
            XDocument document = new XDocument();
            //第三個參數為yes,說明這個xml是單純的xml無任何規定,能隨意寫標簽
            XDeclaration delaration = new XDeclaration("1.0", "utf-8", "yes");
            //文檔聲明寫入文檔
            document.Declaration = delaration;

            //XElement rootNode = new XElement("根節點", "這是根節點的內容,但是一般不放文字");
            XElement rootNode = new XElement("根節點");

            //在根節點內加入兩個有內容的子節點
            XElement sonNode1 = new XElement("子節點1", "我是有文字內容的");
            rootNode.Add(sonNode1);
            XElement sonNode2 = new XElement("子節點2", "我是有文字內容的");
            rootNode.Add(sonNode2);

            //加入有子節點的子節點
            XElement sonNode3 = new XElement("子節點3");
            //這個節點加入子節點
            XElement sunNode1 = new XElement("孫節點", "我有文字內容和屬性");
            //給這個節點設置屬性
            sunNode1.SetAttributeValue("id", "孫節點1好");
            sonNode3.Add(sunNode1);
            rootNode.Add(sonNode3);

            //直接在根節點添加子節點,但是這樣拿不到子節點對象
            rootNode.SetElementValue("子節點4", "我有文字內容");
            //設置屬性
            rootNode.SetAttributeValue("id", "唯一的根節點");

            document.Add(rootNode);
            document.Save("xml文檔.xml");
            Console.WriteLine("ok");
            Console.ReadKey();
        }
開發者ID:RunningStudent,項目名稱:MyLearningCode_CSharp,代碼行數:36,代碼來源:Program.cs

示例8: SaveUserData

 internal void SaveUserData(XElement node)
 {
     node.SetElementValue("ShowComponents", this.buttonShowComponents.Checked);
 }
開發者ID:ChrisLakeZA,項目名稱:duality,代碼行數:4,代碼來源:SceneView.cs

示例9: SetCapabilities

 public void SetCapabilities(XElement options)
 {
     const string manifestUri = "http://schemas.microsoft.com/wlw/manifest/weblog";
     options.SetElementValue(XName.Get("supportsKeywords", manifestUri), "Yes");
     options.SetElementValue(XName.Get("supportsGetTags", manifestUri), "Yes");
     options.SetElementValue(XName.Get("keywordsAsTags", manifestUri), "Yes");
 }
開發者ID:stack72,項目名稱:GiveCamp-London,代碼行數:7,代碼來源:XmlRpcHandler.cs

示例10: GetOutline

        private string GetOutline(int indentLevel, XElement element)
        {
            StringBuilder result = new StringBuilder();
            // TODO
            if (element.Attribute("id") != null)
            {
                //result = result.AppendLine(new string(' ', indentLevel * 2) + element.Attribute("id").Value);
                //foreach (var item in element.Descendants())
                //{
                //    result = result.AppendLine(new string(' ', indentLevel * 2) + item.Value);
                //}
                var test = element.Attribute("id").Value;
                result = result.AppendLine(element.Attribute("id").Value);
                try
                {
                    foreach (var item in element.Descendants())
                    {
                        element.SetElementValue("from", "test");
                        result = result.AppendLine(new string(' ', 4) + item.Name.ToString() + " " + item.Value);
                    }
                }
                catch (Exception e)
                {
            #if DEBUG
                    Console.WriteLine(e.Message);
            #endif
            #if RELEASE
                    Console.WriteLine(e.Message);
                    Logger.Log(e.Message);
            #endif
                }
            }

            foreach (XElement childElement in element.Elements())
            {
                result.Append(GetOutline(indentLevel + 1, childElement));
            }

            return result.ToString();
        }
開發者ID:Janser617,項目名稱:brillianICM,代碼行數:40,代碼來源:Form1.cs

示例11: WriteTexture

        bool WriteTexture(XElement texturesElement, string textureType, string texturePath)
        {
            if (texturePath == null)
                return false;

            var element = texturesElement.Elements("Texture").FirstOrDefault(x => x.Attribute("Map").Value == textureType);
            if (element == null)
            {
                element = new XElement("Texture");

                element.SetAttributeValue("Map", textureType);
                element.SetAttributeValue("File", texturePath);
            }
            else
            {
                element.SetAttributeValue("File", texturePath);

                texturesElement.SetElementValue("Texture", element);
            }

            return true;
        }
開發者ID:nathanpapke,項目名稱:CryMono,代碼行數:22,代碼來源:CharacterAttachmentMaterial.cs

示例12: LoadDBConfig

        private XElement LoadDBConfig(string newcfg)
        {

            //retrieve all the names
            string CommandText = "select id,value from data where grp='" + newcfg + "' and tbl='" + this.sql_tbl + "'";
            SQLiteDataAdapter DB2 = new SQLiteDataAdapter(CommandText, sql_con);
            DataSet DS2 = new DataSet();
            DS2.Reset();
            DB2.Fill(DS2);
            XElement xe = new XElement("Item");
            foreach (string reg in regs)
            {
                xe.Add(reg, "0");
            }
            foreach (DataRow dr in DS2.Tables[0].Rows)
            {
                foreach (string reg in regs)
                {
                    if (reg == dr[0].ToString())
                        xe.SetElementValue(dr[0].ToString(), dr[1].ToString());
                }
            }
            //sql_con.Close();
            return xe;           

        }
開發者ID:imdmmp,項目名稱:kpgweigher,代碼行數:26,代碼來源:SubNode.cs

示例13: AddValue

 protected void AddValue(XElement element, string name, object value)
 {
     //Recurise through the value(s)
     if (value != null && value.GetType().HasElementType && value is System.Collections.IEnumerable)
     {
         //Recurse through the values
         foreach (object item in (System.Collections.IEnumerable)value)
             AddValue(element, name, item);
     }
     else
     {
         element.SetElementValue(name, StringEx.ToString(value));
     }
 }
開發者ID:noahfalk,項目名稱:corefx,代碼行數:14,代碼來源:testspec.cs

示例14: SaveUserData

		internal void SaveUserData(XElement node)
		{
			Camera nativeCamera = this.nativeCamObj.GetComponent<Camera>();

			node.SetElementValue("Perspective", nativeCamera.Perspective);
			node.SetElementValue("FocusDist", nativeCamera.FocusDist);
			XElement bgColorElement = new XElement("BackgroundColor");
			{
				bgColorElement.SetElementValue("R", nativeCamera.ClearColor.R);
				bgColorElement.SetElementValue("G", nativeCamera.ClearColor.G);
				bgColorElement.SetElementValue("B", nativeCamera.ClearColor.B);
				bgColorElement.SetElementValue("A", nativeCamera.ClearColor.A);
			}
			node.Add(bgColorElement);

			XElement snapToGridSizeElement = new XElement("SnapToGridSize");
			node.Add(snapToGridSizeElement);
			snapToGridSizeElement.SetElementValue("X", this.editingUserGuides.GridSize.X);
			snapToGridSizeElement.SetElementValue("Y", this.editingUserGuides.GridSize.Y);
			snapToGridSizeElement.SetElementValue("Z", this.editingUserGuides.GridSize.Z);

			if (this.activeState != null) 
				node.SetElementValue("ActiveState", this.activeState.GetType().GetTypeId());

			XElement stateListNode = new XElement("States");
			foreach (var pair in this.availStates)
			{
				XElement stateNode = new XElement("State");
				stateNode.SetAttributeValue("type", pair.Key.GetTypeId());
				pair.Value.SaveUserData(stateNode);
				if (!stateNode.IsEmpty)
					stateListNode.Add(stateNode);
			}
			if (!stateListNode.IsEmpty)
				node.Add(stateListNode);

			XElement layerListNode = new XElement("Layers");
			foreach (var pair in this.availLayers)
			{
				XElement layerNode = new XElement("Layer");
				layerNode.SetAttributeValue("type", pair.Key.GetTypeId());
				pair.Value.SaveUserData(layerNode);
				if (!layerListNode.IsEmpty)
					layerListNode.Add(layerNode);
			}
			if (!layerListNode.IsEmpty)
				node.Add(layerListNode);
		}
開發者ID:Scottyaim,項目名稱:duality,代碼行數:48,代碼來源:CamView.cs

示例15: AsXml

        public XElement AsXml()
        {
            XElement carXml = new XElement(IsIngame ? "Car" : "DisabledCar");

            carXml.SetAttributeValue("Name", Name);
            carXml.SetAttributeValue("ABS", ABS);
            carXml.SetAttributeValue("AT", AT);

            carXml.SetElementValue("DisplayName", DisplayName);
            carXml.SetElementValue("Description", Description);
            carXml.SetElementValue("Author", Author);

            return carXml;
        }
開發者ID:vlad-zapp,項目名稱:3diModManager,代碼行數:14,代碼來源:CarEntity.cs


注:本文中的System.Xml.Linq.XElement.SetElementValue方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。