public void AddLocation() { //InfoModel.Instance.server.ReadFromClient(InfoModel.Instance.server.client); SimulatorInfo si = ClientSide.Instance.SampleFlightValues(); var emp = InfoModel.Instance; string result = " "; string path = Server.MapPath("~/App_Data/flight1.xml"); if (new FileInfo(path).Length <= 1) { ToXml(InfoModel.Instance, path); } else { XDocument xDocument = XDocument.Load(path); XElement root = xDocument.Element("Datas"); IEnumerable <XElement> rows = root.Descendants("Data"); XElement firstRow = rows.First(); firstRow.AddBeforeSelf( new XElement("Data", new XElement("Lon", si.Lon), new XElement("Lat", si.Lat), new XElement("Rud", si.Rud), new XElement("Thr", si.Thr))); xDocument.Save(path); } }
public void add() { Console.WriteLine("Enter the details of laptop to be added"); Console.ReadKey(); Console.Write("Enter the ID :"); String x = Console.ReadLine(); Console.Write("Enter the Brand :"); String y = Console.ReadLine(); Console.Write("Enter the Model :"); String z = Console.ReadLine(); Console.Write("Enter the Price :"); String w = Console.ReadLine(); XDocument xDocument = XDocument.Load("Laptop.xml"); XElement root = xDocument.Element("Laptops"); IEnumerable <XElement> rows = root.Descendants("Laptop"); XElement firstRow = rows.First(); firstRow.AddBeforeSelf( new XElement("Laptop", new XElement("ID", x), new XElement("brand", y), new XElement("model", z), new XElement("price", w))); xDocument.Save("Laptop.xml"); Console.WriteLine("Laptop Added and Saved"); }
internal virtual void UpdateXml() { if (!_IsXmlValid) { var temp = UpdatingXml; if (temp != null) { temp(this, new EventArgs()); } _IsXmlValid = true; var xNewElement = CreateXmlFromObject(); var xKeyAttr = xNewElement.Attribute(xNsX + "Key"); if (xKeyAttr == null) { xNewElement.Add(new XAttribute(xNsX + "Key", Key)); } else { xKeyAttr.Value = Key; } var parent = _Xml.Parent; if (xNewElement.Parent != parent && parent != null) { _Xml.AddBeforeSelf(xNewElement); _Xml.Remove(); } _Xml = xNewElement; NotifyPropertyChanged("Xml"); } }
//=========================================================================================== private void AddMagickImageCollectionMethods(XElement annotation) { foreach (MethodInfo[] overloads in _GraphicsMagickNET.GetGroupedMagickImageCollectionMethods()) { annotation.AddBeforeSelf(CreateElement(overloads)); } }
//=========================================================================================== private void AddMagickImageProperties(XElement annotation) { foreach (PropertyInfo property in _GraphicsMagickNET.GetMagickImageProperties()) { annotation.AddBeforeSelf(CreateElement(property)); } }
private void AddMagickSettingsMethods(XElement annotation) { foreach (MethodInfo[] overloads in _Types.GetGroupedMagickSettingsMethods()) { annotation.AddBeforeSelf(CreateElement(overloads)); } }
public static void insert(string group, string msg, string ans) { if (msg.IndexOf("\r\n") < 0 & msg != "") { dircheck(group); XElement root = XElement.Load(path + group + ".xml"); XElement read = root.Element(keyNode); if (read == null) { root.Add(new XElement(keyNode, new XElement(keyName, msg), new XElement(valueName, ans) )); } else { read.AddBeforeSelf(new XElement(keyNode, new XElement(keyName, msg), new XElement(valueName, ans) )); } root.Save(path + group + ".xml"); } }
private static void ExtractGeometries(XElement drawingGroupElement, ResKeyInfo resKeyInfo) { //get Name of DrawingGroup var nameDg = drawingGroupElement.Attribute(Nsx + "Key").Value; var name = nameDg.Replace("DrawingGroup", ""); name = GetElemNameFromResKey(name, resKeyInfo); //find this: <GeometryDrawing Brush="{DynamicResource _3d_view_icon_BrushColor}" Geometry="F1 M512,512z M0,0z M436.631,207.445L436.631,298.319z" /> //var geos = drawingGroupElement.XPathSelectElements(".//defns:GeometryDrawing/@defns:Geometry", _nsManager).ToList(); var geos = drawingGroupElement.Descendants() .Where(e => e.Name.LocalName == "GeometryDrawing") .SelectMany(e => e.Attributes()) .Where(a => a.Name.LocalName == "Geometry") .ToList(); foreach (var geo in geos) { //build resourcename int?no = geos.Count > 1 ? geos.IndexOf(geo) + 1 : (int?)null; var localName = BuildGeometryName(name, no, resKeyInfo); //Add this: <Geometry x:Key="cloud_3_iconGeometry">F1 M512,512z M0,0z M409.338,216.254C398.922,351.523z</Geometry> drawingGroupElement.AddBeforeSelf(new XElement(NsDef + "Geometry", new XAttribute(Nsx + "Key", localName), geo.Value)); geo.Value = BuildResKeyReference(localName, false); } }
private void AddSafeDataElement(XElement parent, string name, string value) { XElement element = parent.XPathSelectElement(string.Format( "{0}[@{1}='{2}']", DataStringConstants.ElementNames.DataElement, DataStringConstants.AttributeNames.Name, name)); if (element == null) { // Add a DataElement, but before any SubCheckData elements XElement subCheckDataElementToPrecede = parent.Element(DataStringConstants.ElementNames.SubCheckData); if (subCheckDataElementToPrecede == null) { // There are no SubCheckData elements, so just add the new DataElement parent.Add(new XElement( DataStringConstants.ElementNames.DataElement, new XAttribute(DataStringConstants.AttributeNames.Name, name), new XAttribute(DataStringConstants.AttributeNames.Value, value))); } else { subCheckDataElementToPrecede.AddBeforeSelf(new XElement( DataStringConstants.ElementNames.DataElement, new XAttribute(DataStringConstants.AttributeNames.Name, name), new XAttribute(DataStringConstants.AttributeNames.Value, value))); } } else { XAttribute valueAttribute = element.Attribute(DataStringConstants.AttributeNames.Value); valueAttribute.Value = value; } }
internal static string AddFingerprintTextProcessor(XDocument rulePackXDoc, Fingerprint fingerprint) { ArgumentValidator.ThrowIfNull("rulePackXDoc", rulePackXDoc); ArgumentValidator.ThrowIfNull("fingerprint", fingerprint); XElement xelement = rulePackXDoc.Descendants(XmlProcessingUtils.GetMceNsQualifiedNodeName("LocalizedStrings")).FirstOrDefault <XElement>(); if (xelement == null) { throw new ClassificationRuleCollectionInvalidObjectException(Strings.ClassificationRuleCollectionInvalidObject); } XElement fingerprintProcessor = XmlProcessingUtils.GetFingerprintProcessor(rulePackXDoc, fingerprint); if (fingerprintProcessor == null) { fingerprint.Identity = Guid.NewGuid().ToString(); fingerprint.ActualDescription = fingerprint.Description; xelement.AddBeforeSelf(fingerprint.ToXElement()); } else { fingerprint.Identity = XmlProcessingUtils.GetAttributeValue(fingerprintProcessor, "id"); string attributeValue = XmlProcessingUtils.GetAttributeValue(fingerprintProcessor, "description"); if (string.IsNullOrEmpty(attributeValue) && !string.IsNullOrEmpty(fingerprint.Description)) { fingerprintProcessor.SetAttributeValue("description", fingerprint.Description); fingerprint.ActualDescription = fingerprint.Description; } else { fingerprint.ActualDescription = attributeValue; } } return(fingerprint.Identity); }
private void AddMagickImageCollectionResultMethods(XElement annotation) { foreach (MethodInfo[] overloads in _Types.GetGroupedMagickImageCollectionResultMethods()) { annotation.AddBeforeSelf(CreateElement(overloads)); } }
public void InvalidNodeTypes() { runWithEvents = (bool)Params[0]; var root = new XElement("root", new XAttribute("a", "b"), new XElement("here"), "tests"); var rootCopy = new XElement(root); XElement elem = root.Element("here"); object[] nodes = { new XAttribute("xx", "yy"), new XDocument(), new XDocumentType("root", null, null, null) }; if (runWithEvents) { eHelper = new EventsHelper(elem); } foreach (object o in nodes) { try { elem.AddBeforeSelf(o); if (runWithEvents) { eHelper.Verify(XObjectChange.Add, o); } TestLog.Compare(false, "Should fail!"); } catch (ArgumentException) { TestLog.Compare(XNode.DeepEquals(root, rootCopy), "root.DeepEquals(rootCopy)"); } } }
//TODO: USE table ID instead private static void PopulateRRLogDefTables(ref XDocument xmlDoc, string outPath, Dictionary <string, Table> ramTableList, string ident) { foreach (KeyValuePair <string, Table> table in ramTableList) { string xp = "./logger/protocols/protocol/ecuparams/ecuparam[@name='" + table.Key.ToString() + "']"; XElement exp = xmlDoc.XPathSelectElement(xp); string cxp = "./logger/protocols/protocol/ecuparams/ecuparam[@name='" + table.Key.ToString() + "']/conversions"; XElement cexp = xmlDoc.XPathSelectElement(cxp); if (exp != null) { string ch = "//ecuparam[@id='" + table.Key.ToString() + "']/ecu[@id='" + ident + "']"; XElement check = exp.XPathSelectElement(ch); if (check != null) { if (check.Value != table.Value.xml.Value) { check.Remove(); } else { continue; } } cexp.AddBeforeSelf(table.Value.xml); } } xmlDoc.SaveToFile(outPath); }
/// <summary> /// 添加一条记录 /// </summary> /// <param name="group"></param> /// <param name="msg"></param> /// <param name="ans"></param> public static void Add(string group, string msg, string ans) { if (msg.IndexOf("\r\n") < 0 & msg != "") { lock (XmlChangeLock) { XElement root = GetXml(group); XElement read = root.Element(keyNode); if (read == null) { root.Add(new XElement(keyNode, new XElement(keyName, msg), new XElement(valueName, ans) )); } else { read.AddBeforeSelf(new XElement(keyNode, new XElement(keyName, msg), new XElement(valueName, ans) )); } if (!Directory.Exists(path)) { Directory.CreateDirectory(path); } root.Save(path + group + ".xml"); } } }
protected void AddOrUpdateNameValuePairDataElement(XElement parentElement, string name, string value) { XElement element = parentElement.XPathSelectElement(string.Format( "{0}[@{1}='{2}']", DataStringConstants.ElementNames.DataElement, DataStringConstants.AttributeNames.Name, name)); if (element == null) { XElement elementToPrecede = parentElement.Element(DataStringConstants.ElementNames.DataElement); if (elementToPrecede == null) { parentElement.Add(new XElement( DataStringConstants.ElementNames.DataElement, new XAttribute(DataStringConstants.AttributeNames.Name, name), new XAttribute(DataStringConstants.AttributeNames.Value, value))); } else { elementToPrecede.AddBeforeSelf(new XElement( DataStringConstants.ElementNames.DataElement, new XAttribute(DataStringConstants.AttributeNames.Name, name), new XAttribute(DataStringConstants.AttributeNames.Value, value))); } } else { XAttribute valueAttribute = element.Attribute(DataStringConstants.AttributeNames.Value); valueAttribute.Value = value; } }
private void AddMagickSettingsProperties(XElement annotation) { foreach (PropertyInfo property in _Types.GetMagickSettingsProperties()) { annotation.AddBeforeSelf(CreateElement(property)); } }
private void buttonAddFav_Click(object sender, EventArgs e) { //GET NEW NAME AND URL string Name = textBoxAddName.Text; string URL = textBoxFavURL.Text; //CHECK IF THE FILE EXISTS if (!File.Exists("myFavorites.xml")) { //IF FILE DOES NOT EXIST, CREATE NEW FILE AND ADD FIRST ENTRY XmlWriterSettings xmlWriterSettings = new XmlWriterSettings(); xmlWriterSettings.Indent = true; xmlWriterSettings.NewLineOnAttributes = true; using (XmlWriter xmlWriter = XmlWriter.Create("myFavorites.xml", xmlWriterSettings)) { xmlWriter.WriteStartDocument(); xmlWriter.WriteStartElement("Favorites"); xmlWriter.WriteStartElement("Details"); xmlWriter.WriteElementString("Fav_ID", favCount.ToString()); xmlWriter.WriteElementString("Name", Name); xmlWriter.WriteElementString("URL", URL); xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); xmlWriter.WriteEndDocument(); xmlWriter.Flush(); xmlWriter.Close(); } } else { //IF FILE EXISTS, ADD NEW ENTRY XDocument xDocument = XDocument.Load("myFavorites.xml"); XElement root = xDocument.Element("Favorites"); IEnumerable <XElement> rows = root.Descendants("Details"); XElement firstRow = rows.First(); firstRow.AddBeforeSelf( new XElement("Details", new XElement("Fav_ID", favCount.ToString()), new XElement("Name", Name), new XElement("URL", URL))); xDocument.Save("myFavorites.xml"); } //INCREMENT FAVCOUNT favCount++; //REPLACE OLD FAV COUNT File.WriteAllText("favCount.txt", String.Empty); File.WriteAllText("favCount.txt", favCount.ToString()); //CONFIRMATION MESSAGE TO THE USER MessageBox.Show(Name + " added to Favorites!"); //CLEAR THE FORM IN CASE USER WANTS TO ADD MORE ENTRIES textBoxAddName.Clear(); textBoxFavURL.Clear(); }
public void WriteFile(SystemAction sysAction) { if (File.Exists(fileName)) { var fileInfo = new FileInfo(fileName); if (fileInfo.Length >= 100000) { string currentTimeString = fileInfo.CreationTime.ToString("yyyyMMddhhmmss"); string backUpFileName = fileInfo.Name.Substring(0, fileInfo.Name.Length - 4) + "_" + currentTimeString + fileInfo.Extension; if (!File.Exists(backUpFileName)) { File.Move(fileName, backUpFileName); } if (File.Exists(fileName)) { File.Delete(fileName); } } } if (!File.Exists(fileName)) { XmlWriterSettings xmlWriterSettings = new XmlWriterSettings(); xmlWriterSettings.Indent = true; xmlWriterSettings.NewLineOnAttributes = true; using (XmlWriter xmlWriter = XmlWriter.Create(fileName, xmlWriterSettings)) { xmlWriter.WriteStartDocument(); xmlWriter.WriteStartElement("SysActions"); xmlWriter.WriteStartElement("Action"); xmlWriter.WriteElementString("OrderNo", sysAction.OrderNo.ToString()); xmlWriter.WriteElementString("CurrentAction", sysAction.CurrentAction.ToString()); xmlWriter.WriteElementString("ActionTime", sysAction.ActionTime.ToString()); xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); xmlWriter.WriteEndDocument(); xmlWriter.Flush(); xmlWriter.Close(); } } else { XDocument xDocument = XDocument.Load(fileName); XElement root = xDocument.Element("SysActions"); IEnumerable <XElement> rows = root.Descendants("Action"); XElement firstRow = rows.First(); firstRow.AddBeforeSelf( new XElement("Action", new XElement("OrderNo", sysAction.OrderNo.ToString()), new XElement("CurrentAction", sysAction.CurrentAction.ToString()), new XElement("ActionTime", sysAction.ActionTime.ToString()) )); xDocument.Save(fileName); } }
protected void Button1_Click(object sender, EventArgs e) { String fname = Convert.ToString(first_name.Value); String lname = Convert.ToString(last_name.Value); String em = Convert.ToString(email.Value); String pwd = Convert.ToString(password.Value); String pwdConf = Convert.ToString(password_confirmation.Value); //string script = string.Format("alert('{0}');", fname+lname+em+pwd+pwdConf); //Page page = HttpContext.Current.CurrentHandler as Page; //if (page != null && !page.ClientScript.IsClientScriptBlockRegistered("alert")) //{ // page.ClientScript.RegisterClientScriptBlock(page.GetType(), "alert", script, true /* addScriptTags */); //} if (!File.Exists("F:\\Users.xml")) { XmlWriterSettings xmlWriterSettings = new XmlWriterSettings(); xmlWriterSettings.Indent = true; xmlWriterSettings.NewLineOnAttributes = true; using (XmlWriter xmlWriter = XmlWriter.Create("F:\\Users.xml", xmlWriterSettings)) { xmlWriter.WriteStartDocument(); xmlWriter.WriteStartElement("Users"); xmlWriter.WriteStartElement("Record"); xmlWriter.WriteElementString("FirstName", fname); xmlWriter.WriteElementString("LastName", lname); xmlWriter.WriteElementString("Email", em); xmlWriter.WriteElementString("Password", pwd); xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); xmlWriter.WriteEndDocument(); xmlWriter.Flush(); xmlWriter.Close(); } } else { XDocument xDocument = XDocument.Load("F:\\Users.xml"); XElement root = xDocument.Element("Users"); IEnumerable <XElement> rows = root.Descendants("Record"); XElement firstRow = rows.First(); firstRow.AddBeforeSelf( new XElement("Record", new XElement("FirstName", fname), new XElement("LastName", lname), new XElement("Email", em), new XElement("Password", pwd))); xDocument.Save("F:\\Test.xml"); } }
public static void AddTof(WordprocessingDocument doc, XElement addBefore, string switches, int?rightTabPos) { UpdateFontTablePart(doc); UpdateStylesPartForTof(doc); UpdateStylesWithEffectsPartForTof(doc); if (rightTabPos == null) { rightTabPos = 9350; } // {0} rightTabPosition (default = 9350) // {1} switches string xmlString = @"<w:p xmlns:w='http://schemas.openxmlformats.org/wordprocessingml/2006/main'> <w:pPr> <w:pStyle w:val='TableofFigures'/> <w:tabs> <w:tab w:val='right' w:leader='dot' w:pos='{0}'/> </w:tabs> <w:rPr> <w:noProof/> </w:rPr> </w:pPr> <w:r> <w:fldChar w:fldCharType='begin' dirty='true'/> </w:r> <w:r> <w:instrText xml:space='preserve'> {1} </w:instrText> </w:r> <w:r> <w:fldChar w:fldCharType='separate'/> </w:r> <w:r> <w:fldChar w:fldCharType='end'/> </w:r> </w:p>"; XElement paragraph = XElement.Parse(String.Format(xmlString, rightTabPos, switches)); XDocument mainXDoc = doc.MainDocumentPart.GetXDocument(); addBefore.AddBeforeSelf(paragraph); doc.MainDocumentPart.PutXDocument(); XDocument settingsXDoc = doc.MainDocumentPart.DocumentSettingsPart.GetXDocument(); XElement updateFields = settingsXDoc.Descendants(W.updateFields).FirstOrDefault(); if (updateFields != null) { updateFields.Attribute(W.val).Value = "true"; } else { updateFields = new XElement(W.updateFields, new XAttribute(W.val, "true")); settingsXDoc.Root.Add(updateFields); } doc.MainDocumentPart.DocumentSettingsPart.PutXDocument(); }
public override void InsertGraterThan(XElement target, XElement left, XElement right, long id, ElementType type) { var code = MethodPrefix + "WriteGraterThan(" + id + "," + (int)type + "," + left.Value + "," + right.Value + ")"; target.AddBeforeSelf(new XElement("TOKEN", code)); target.Remove(); }
void DoInlineImport(XElement import, InlineImport inlineImport) { var importPath = ExpandPath(SourceDirectory, import.Attribute("Project").Value); var inlinedDoc = XDocument.Load(importPath); RelocateImports(Path.GetDirectoryName(importPath), inlinedDoc); var project = inlinedDoc.Root; List <XNode> filteredNodes = new List <XNode>(); bool inSample = true; foreach (var node in project.Nodes()) { if (node is XComment) { var comment = (XComment)node; if (comment.Value.Contains("[[NOT IN SAMPLE]]")) { inSample = false; continue; } else if (comment.Value.Contains("[[IN SAMPLE]]")) { inSample = true; continue; } } if (inSample) { filteredNodes.Add(node); } } import.AddBeforeSelf(filteredNodes); if (inlineImport.Elements.Count > 0) { import.AddBeforeSelf(inlineImport.Elements); } import.Remove(); }
internal void AddElementInPosition(XName name, XElement parentElement, bool addToExisting, XTypedElement xObj) { NamedContentModelEntity namedEntity = this.GetNamedEntity(name); if (namedEntity == null) { throw new LinqToXsdException(string.Concat("Name does not belong in content model. Cannot set value for child ", name.LocalName)); } EditAction editAction = EditAction.None; XElement elementMarker = this.FindElementPosition(namedEntity, parentElement, addToExisting, out editAction); XElement newElement = XTypedServices.GetXElement(xObj, name); Debug.Assert(xObj != null); switch (editAction) { case EditAction.AddBefore: { elementMarker.AddBeforeSelf(newElement); return; } case EditAction.AddAfter: { return; } case EditAction.Append: { parentElement.Add(newElement); return; } case EditAction.Update: { elementMarker.AddBeforeSelf(newElement); elementMarker.Remove(); return; } default: { return; } } }
private void ReplacePaths(XElement annotation) { foreach (ConstructorInfo[] constructors in _Types.GetPaths()) { annotation.AddBeforeSelf(CreateElement(constructors)); } annotation.Remove(); }
private void ReplaceEnums(XElement annotation) { foreach (Type enumType in _Types.GetEnums()) { annotation.AddBeforeSelf(CreateEnumElement(enumType)); } annotation.Remove(); }
public static XElement AddBeforeChild(this XElement xele, Func <XElement, bool> predicate, params object[] content) { XElement ele = (from e in xele.Elements() where predicate(e) select e).FirstOrDefault(); ele.AddBeforeSelf(content); return(xele); }
/// <summary> /// Starting with the innermost nodes, replace all lookups with identities /// </summary> /// <param name="xElement"></param> private void ReplaceReferenceLookupsWithIdentities(XElement xElement) { XElement newIdentity = null; var ns = xElement.Name.Namespace; if (_regex.IsMatch(xElement.Name.LocalName)) { var typeName = _regex.Match(xElement.Name.LocalName).Groups["TypeName"].Value; var lookup = xElement.Element(ns + $"{typeName}Lookup"); var identity = xElement.Element(ns + $"{typeName}Identity"); if (lookup != null && identity == null) { var hashBytes = _hashProvider.Hash(lookup.ToString()); var hash = _hashProvider.BytesToStr(hashBytes); if (_hashIdentities.ContainsKey(hash) && _hashIdentities[hash] != null) { newIdentity = XElement.Parse(_hashIdentities[hash].ToString()); lookup.AddBeforeSelf( new XComment( $"This {typeName}Lookup entity was used to populate its {typeName}Identity sibling")); } else { lookup.AddBeforeSelf( new XComment( $"No {typeName}Identity could be retrieved for this {typeName}Lookup entity")); } } foreach (var element in xElement.Elements()) { ReplaceReferenceLookupsWithIdentities(element); } if (newIdentity == null) { return; } xElement.Add(newIdentity); newIdentity.AddBeforeSelf( new XComment( $"This {typeName}Identity entity was retrieved from the API using the provided {typeName}Lookup information")); } else { foreach (var element in xElement.Elements()) { ReplaceReferenceLookupsWithIdentities(element); } } }
//=========================================================================================== private void ReplaceDrawables(XElement annotation) { foreach (ConstructorInfo[] constructors in _GraphicsMagickNET.GetDrawables()) { annotation.AddBeforeSelf(CreateElement(constructors)); } annotation.Remove(); }
private void Registration() { XDocument doc = XDocument.Load("Test.xml"); bool exsist = false; foreach (XElement cell in doc.Element("Instagram").Elements("User")) { if (cell.Element("Name").Value == CurrentUser.Name) { exsist = true; NText = "User already exist!"; } } CurrentUser.Validate(); if (CurrentUser.IsValid && !exsist) { Users.Add(CurrentUser); CurrentViewModel = userViewModel; userViewModel = new UserViewModel(CurrentUser.Name); if (!File.Exists("Test.xml")) { XmlWriterSettings xmlWriterSettings = new XmlWriterSettings(); xmlWriterSettings.Indent = true; xmlWriterSettings.NewLineOnAttributes = true; using (XmlWriter xmlWriter = XmlWriter.Create("Test.xml", xmlWriterSettings)) { xmlWriter.WriteStartDocument(); xmlWriter.WriteStartElement("Instagram"); xmlWriter.WriteStartElement("User"); xmlWriter.WriteElementString("Name", CurrentUser.Name); xmlWriter.WriteElementString("Password", CurrentUser.Password); xmlWriter.WriteEndElement(); xmlWriter.WriteEndElement(); xmlWriter.WriteEndDocument(); xmlWriter.Flush(); xmlWriter.Close(); } } else { XDocument xDocument = XDocument.Load("Test.xml"); XElement root = xDocument.Element("Instagram"); IEnumerable <XElement> rows = root.Descendants("User"); XElement firstRow = rows.First(); firstRow.AddBeforeSelf( new XElement("User", new XElement("Name", CurrentUser.Name), new XElement("Password", CurrentUser.Password))); xDocument.Save("Test.xml"); } } }
//=========================================================================================== private void ReplaceEnums(XElement annotation) { foreach (Type enumType in _GraphicsMagickNET.Enums) { annotation.AddBeforeSelf(CreateEnumElement(enumType)); } annotation.Remove(); }