public void CreateDumpFile() { try { System.Xml.Linq.XDocument doc = new System.Xml.Linq.XDocument(); System.Xml.Linq.XElement xel = new System.Xml.Linq.XElement("DumpList"); foreach (var item in EquipmentManagerInstance.EquipmentList) { var list = new List<object>(); var xml = Utility.UtilityClass.ObjectToXml(item.Value); if (xml != null) { var equipXml = new System.Xml.Linq.XElement("Equipment"); var name = new System.Xml.Linq.XElement("Name"); name.Value = item.Key; var value = new System.Xml.Linq.XElement("Value"); value.Add(xml); equipXml.Add(name); equipXml.Add(value); xel.Add(equipXml); } } doc.Add(xel); string filename = DateTime.Now.ToString("yyyy-MM-dd_HHmmss") + ".xml"; string path = System.IO.Path.Combine(ConfigClasses.GlobalConst.ROOT_PATH, "DumpFile"); if (System.IO.Directory.Exists(path) == false) System.IO.Directory.CreateDirectory(path); string pathAndFilename = System.IO.Path.Combine(path, filename); doc.Save(pathAndFilename); } catch (Exception e) { System.Diagnostics.Trace.WriteLine(e.ToString()); } }
private void WriteSettingObjectRecursively(System.Xml.Linq.XElement element, SettingItemBase settingItem) { if (settingItem is SettingItemGroup) { var settingItemGroup = settingItem as SettingItemGroup; if (settingItemGroup.HasAttributes) { foreach (var attr in settingItemGroup.Attributes) { element.Add(new System.Xml.Linq.XAttribute(attr.Name, attr.Value)); } } } if (settingItem.HasChildren) { bool hasChildren = false; foreach (var child in settingItem.Children) { hasChildren = child.HasChildren; var xElement = hasChildren ? new System.Xml.Linq.XElement(child.Name) : new System.Xml.Linq.XElement(child.Name, child.Value); element.Add(xElement); this.WriteSettingObjectRecursively(xElement, child); } } }
public static System.Xml.Linq.XElement RemoveAllNamespaces(System.Xml.Linq.XElement rootElement) { System.Xml.Linq.XElement xElement = new System.Xml.Linq.XElement(rootElement.Name.LocalName); if (rootElement.HasAttributes) { foreach (System.Xml.Linq.XAttribute attribute in rootElement.Attributes()) { if (!attribute.IsNamespaceDeclaration) { if (rootElement.Name.LocalName == "Category") { xElement.Add(attribute); } else { if (attribute.Name.ToString() == "{http://www.w3.org/2001/XMLSchema-instance}type" || attribute.Name.ToString() == "{http://www.w3.org/2001/XMLSchema-instance}nil") { // We dont want xsi: attribute // except for certain types where we will inject our own value if (rootElement.Name.LocalName == "Activity" && attribute.Name.ToString() == "{http://www.w3.org/2001/XMLSchema-instance}type" && attribute.Value.EndsWith("RepairAndMaintenanceActivity")) { attribute.Value = "RepairAndMaintenanceActivity"; xElement.Add(attribute); } if (rootElement.Name.LocalName == "Activity" && attribute.Name.ToString() == "{http://www.w3.org/2001/XMLSchema-instance}type" && attribute.Value.EndsWith("CustomerActivity")) { attribute.Value = "CustomerActivity"; xElement.Add(attribute); } } else { xElement.Add(attribute); } } } } } if (rootElement.HasElements) { // Recurse the structure foreach (System.Xml.Linq.XElement childElement in rootElement.Elements()) { xElement.Add(RemoveAllNamespaces(childElement)); } } else { // Take the current value across xElement.Value = rootElement.Value; } return xElement; }
/// <summary> /// 必须重写这个方法,返回的数据就真正保存到txt的数据 /// </summary> /// <returns>字符串信息</returns> public override string ToSaveString( ) { // 此处举例采用xml格式存储 System.Xml.Linq.XElement element = new System.Xml.Linq.XElement("Settings"); element.Add(new System.Xml.Linq.XElement(nameof(IpAddress), IpAddress)); element.Add(new System.Xml.Linq.XElement(nameof(Port), Port.ToString( ))); return(element.ToString( )); }
public System.Xml.Linq.XElement ToXML() { System.Xml.Linq.XElement ele = new System.Xml.Linq.XElement("Stop"); ele.Add(new System.Xml.Linq.XAttribute("Name", this.Name)); ele.Add(new System.Xml.Linq.XAttribute("Time", this.Time)); ele.Add(new System.Xml.Linq.XAttribute("PickUp", this.PickUp)); ele.Add(new System.Xml.Linq.XAttribute("DropOff", this.DropOff)); ele.Add(new System.Xml.Linq.XAttribute("Normal", this.Normal)); return ele; }
public static void SaveBlogConnectionInfo(MP.BlogConnectionInfo coninfo, string filename) { var doc = new System.Xml.Linq.XDocument(); var p = new System.Xml.Linq.XElement("blogconnectioninfo"); doc.Add(p); p.Add(new System.Xml.Linq.XElement("blogurl", coninfo.BlogUrl)); p.Add(new System.Xml.Linq.XElement("blogid", coninfo.BlogId)); p.Add(new System.Xml.Linq.XElement("metaweblog_url", coninfo.MetaWeblogUrl)); p.Add(new System.Xml.Linq.XElement("username", coninfo.Username)); p.Add(new System.Xml.Linq.XElement("password", coninfo.Password)); doc.Save(filename); }
public void Save(string filename) { var doc = new System.Xml.Linq.XDocument(); var p = new System.Xml.Linq.XElement("blogconnectioninfo"); doc.Add(p); p.Add(new System.Xml.Linq.XElement("blogurl", this.BlogURL)); p.Add(new System.Xml.Linq.XElement("blogid", this.BlogID)); p.Add(new System.Xml.Linq.XElement("metaweblog_url", this.MetaWeblogURL)); p.Add(new System.Xml.Linq.XElement("username", this.Username)); p.Add(new System.Xml.Linq.XElement("password", this.Password)); doc.Save(filename); }
public System.Xml.Linq.XElement ToXML() { System.Xml.Linq.XElement ele = new System.Xml.Linq.XElement("Location"); ele.Add(new System.Xml.Linq.XAttribute("RealName", this.RealName)); ele.Add(new System.Xml.Linq.XAttribute("Latitude", this.Latitude)); ele.Add(new System.Xml.Linq.XAttribute("Longtitude", this.Longtitude)); ele.Add(new System.Xml.Linq.XAttribute("LocationType", this.LocationType)); foreach (string s in aliases) { ele.Add(new System.Xml.Linq.XElement("Alias", s)); } return ele; }
public static System.Xml.Linq.XElement RS_AddElement(this System.Xml.Linq.XElement el, string name) { var child = new System.Xml.Linq.XElement(RDLINFO.RS_Namespace.GetName(name)); el.Add(child); return(child); }
public bool AddShutterEstimate(shutters shutter) { System.Xml.Linq.XElement customerLocationPics = new System.Xml.Linq.XElement("root"); foreach (var r in shutter.CustomerLocationPics) { var varPics = new System.Xml.Linq.XElement("pics", new System.Xml.Linq.XElement("pic", r.LocationPicture)); customerLocationPics.Add(varPics); } shutter.locationpicture = customerLocationPics.ToString(); System.Xml.Linq.XElement shutterAccessoriesList = new System.Xml.Linq.XElement("root"); foreach (var r in shutter.ShutterAccessories) { if (r.accessories != null) { var varPics = new System.Xml.Linq.XElement("accessories", new System.Xml.Linq.XElement("accessorie", "<![CDATA[" + r.accessories + "]]> "), new System.Xml.Linq.XElement("qty", r.quantity)); shutterAccessoriesList.Add(varPics); } } shutter.ShutterAccessorie = shutterAccessoriesList.ToString(); return(shuttersDAL.Instance.AddShutterEstimate(shutter)); }
private void Create(string projectName) { List <ProjectTemplate> templateList = new List <ProjectTemplate>(); foreach (var item in checkedListBoxTemplates.CheckedItems) { ProjectTemplate projectTemplate = new ProjectTemplate(); projectTemplate.TemplateName = item.ToString(); projectTemplate.ScreenParameters["OutputDirectory"] = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "projects", textBoxName.Text, "Output"); projectTemplate.ParametersTree = new System.Xml.Linq.XElement("parameterTree", ""); System.Xml.Linq.XElement root = new System.Xml.Linq.XElement("root"); root.SetAttributeValue("name", "root"); root.Add(new System.Xml.Linq.XElement("children")); projectTemplate.ParametersTree.Add(root); templateList.Add(projectTemplate); } Project project = new Project(); project.Name = projectName; project.ProjectTemplateList.Clear(); project.ProjectTemplateList.AddRange(templateList); ProjectContainer.GetInstance().UpdateProject(project); ProjectContainer.GetInstance().Save(); ProjectContainer.GetInstance().Reload(this, EventArgs.Empty); Classes.Mediation.FormMediator.GetInstance().SendMessage("Project Created"); }
public static System.Xml.Linq.XElement AddDivElement(this System.Xml.Linq.XElement parent) { var el_div = new System.Xml.Linq.XElement("div"); parent.Add(el_div); return(el_div); }
public override void FillAnswerFileNode(System.Xml.Linq.XElement answerFileNode, CustomQuestionProperties props) { if (props.ContainsAttribute(_valueGuid)) { answerFileNode.Add(new System.Xml.Linq.XAttribute(_valueGuid.ToString(), props.GetAttributeString(_valueGuid))); } }
private static void LoadSql(string fileName, string sql, long elapsed) { try { System.Xml.Linq.XDocument xmlDoc = null; System.Xml.Linq.XElement rootElement = null; const string RootName = "SQL"; if (File.Exists(fileName)) { xmlDoc = System.Xml.Linq.XDocument.Load(fileName); rootElement = xmlDoc.Element(RootName); } else { xmlDoc = new System.Xml.Linq.XDocument(); rootElement = new System.Xml.Linq.XElement(RootName); xmlDoc.Add(rootElement); } var parentElement = new System.Xml.Linq.XElement("Entry", new System.Xml.Linq.XAttribute("datetime", DateTime.Now.ToString("yyyy-MM-ddTHH:mm:ss.fff")), new System.Xml.Linq.XAttribute("elapsed", elapsed.ToString())); parentElement.Add(new System.Xml.Linq.XElement("sql", new System.Xml.Linq.XCData(sql))); rootElement.Add(parentElement); xmlDoc.Save(fileName); } catch (Exception ex) { //Do Nothing } }
public static System.Xml.Linq.XElement AddH1Element(this System.Xml.Linq.XElement parent, string text) { var el_h1 = new System.Xml.Linq.XElement("h1", text); parent.Add(el_h1); return(el_h1); }
public static System.Xml.Linq.XElement AddParagraphElement(this System.Xml.Linq.XElement el_body) { var el_para = new System.Xml.Linq.XElement("p"); el_body.Add(el_para); return(el_para); }
public void Save(string fileName) { // 创建文件对象。 System.IO.FileInfo fileInfo = new System.IO.FileInfo(fileName); // 如果文件对象所在目录不存在,则创建。 if (!System.IO.Directory.Exists(fileInfo.DirectoryName)) { System.IO.Directory.CreateDirectory(fileInfo.DirectoryName); } // 创建Xml文档。 System.Xml.Linq.XDocument xDocument = new System.Xml.Linq.XDocument(new System.Xml.Linq.XDeclaration("1.0", "utf-8", "")); // 添加Xml根节点。 xDocument.Add(new System.Xml.Linq.XElement(XmlRootName)); // 遍历配置文件中的配置组集合。 foreach (ConfigurationGroup configurationGroup in _ConfigurationGroupDictionary.Values) { // 创建并添加Xml组节点。 System.Xml.Linq.XElement xGroup = new System.Xml.Linq.XElement(XmlGroupNodeName); xGroup.SetAttributeValue(XmlKeyAttributeName, configurationGroup.Key); xDocument.Root.Add(xGroup); // 遍历配置组中的配置项集合。 foreach (ConfigurationItem configurationItem in configurationGroup) { // 创建并添加Xml项节点。 System.Xml.Linq.XElement xItem = new System.Xml.Linq.XElement(XmlItemNodeName); xItem.SetAttributeValue(XmlKeyAttributeName, configurationItem.Key); xItem.SetAttributeValue(XmlValueAttributeName, configurationItem.Encrypted ? Studio.Security.DESManager.Encrypt(configurationItem.Value) : configurationItem.Value); xItem.SetAttributeValue(XmlEncryptedAttributeName, configurationItem.Encrypted); xGroup.Add(xItem); } } // 保存到文件。 xDocument.Save(fileInfo.FullName); }
public static System.Xml.Linq.XElement RS_SetElementValue(this System.Xml.Linq.XElement el, string name, string val) { var child = new System.Xml.Linq.XElement(RDLINFO.RS_Namespace.GetName(name)); el.Add(child); child.Value = val; return(child); }
public void Add(String filename, Boolean stream) { try { xelement.Add(new System.Xml.Linq.XElement("Media", new System.Xml.Linq.XElement("Path", filename), new System.Xml.Linq.XElement("Stream", stream))); } catch { } }
public static System.Xml.Linq.XElement AddAnchorElement(this System.Xml.Linq.XElement parent, string href, string text) { var el_anchor = new System.Xml.Linq.XElement("a"); el_anchor.SetAttributeValue("href", href); el_anchor.Value = text; parent.Add(el_anchor); return(el_anchor); }
public void AddPlaylist(String playlistName) { try { System.Xml.Linq.XElement newTag = new System.Xml.Linq.XElement("Playlist", new System.Xml.Linq.XAttribute("name", playlistName)); xelement.Add(newTag); } catch { Console.WriteLine("FAILED AddPlaylist catch"); } }
public static System.Xml.Linq.XElement AddParagraphElement(this System.Xml.Linq.XElement el_body, string text) { var el_para = new System.Xml.Linq.XElement("p"); el_body.Add(el_para); if (text != null) { el_para.Value = text; } return(el_para); }
private System.Xml.Linq.XElement GetPersons(System.Xml.Linq.XElement xWaitList) { System.Xml.Linq.XElement xPersons = xWaitList.Element("Persons"); if (xPersons == null) { xPersons = new System.Xml.Linq.XElement("Persons"); xWaitList.Add(xPersons); } return(xPersons); }
public static Exception Log(System.Xml.Linq.XElement xElement, LogLevel logLevel) { // Filter entries below log level if (xElement == null || logLevel < MyLogLevel) { return(null); } try { var logEntry = new System.Xml.Linq.XElement("LogEntry"); logEntry.Add(new System.Xml.Linq.XAttribute("Date", DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss"))); logEntry.Add(new System.Xml.Linq.XAttribute("LogLevel", logLevel)); logEntry.Add(xElement); return(WriteLogEntryToFile(logEntry)); } catch (Exception ex) { return(ex); } }
public void saveSetting(string xmlFilename = null) { var xe = new System.Xml.Linq.XElement(settingXmlName); foreach (var k in settingData.Keys) { xe.Add(new System.Xml.Linq.XElement(k, settingData[k])); } var xmlPath = getXmlPath(xmlFilename); xe.Save(xmlPath); }
public static System.Xml.Linq.XElement RS_SetElementValueCOND <T>(this System.Xml.Linq.XElement el, string name, T?val, Func <T, string> fs) where T : struct { if (val.HasValue) { var child = new System.Xml.Linq.XElement(RDLINFO.RS_Namespace.GetName(name)); el.Add(child); child.Value = fs(val.Value); return(child); } else { return(null); } }
public static System.Xml.Linq.XElement RS_SetElementValueCOND(this System.Xml.Linq.XElement el, string name, Viziblr.Reporting.RDL2005.Color color) { if (color.HasValue) { var child = new System.Xml.Linq.XElement(RDLINFO.RS_Namespace.GetName(name)); el.Add(child); child.Value = color.ToString(); return(child); } else { return(null); } }
public static string RemoveAllNamespaces(string xmlDocument) { // Firstly remove all our known namespace values using simple string.Replace xmlDocument = Base.RemoveXmlNamespaces(xmlDocument); // To remove Namespaces we have to recreate the Element from the incoming structure // Load up an XElement with the XML document contents System.Xml.Linq.XElement rootElement = System.Xml.Linq.XElement.Parse(xmlDocument); System.Xml.Linq.XElement rootElementWithNoNamespace = new System.Xml.Linq.XElement(rootElement.Name.LocalName); // We want to retain Namespace attributes on the root (for LookupData anyway) // Take any existing Namespace (and other attributes) on the top level Element foreach (System.Xml.Linq.XAttribute attribute in rootElement.Attributes()) { rootElementWithNoNamespace.Add(attribute); } if (rootElement.HasElements) { foreach (System.Xml.Linq.XElement childElement in rootElement.Elements()) { rootElementWithNoNamespace.Add(RemoveAllNamespaces(childElement)); } } return rootElementWithNoNamespace.ToString(); }
public static System.Xml.Linq.XElement RS_SetElementValueCONDBOOL(this System.Xml.Linq.XElement el, string name, bool?val) { if (val.HasValue) { var child = new System.Xml.Linq.XElement(RDLINFO.RS_Namespace.GetName(name)); el.Add(child); child.Value = val.Value ? "true" : "false"; return(child); } else { return(null); } }
public override string ToString() { string value = $"{Value}"; var result = new System.Xml.Linq.XDocument(new System.Xml.Linq.XElement("tree", new System.Xml.Linq.XAttribute("value", value))); this.Aggregate(result, (whole, next) => { var subtree = new System.Xml.Linq.XElement("tree", new System.Xml.Linq.XAttribute("key", next.Key)); subtree.Add(System.Xml.Linq.XElement.Parse(next.Value.ToString())); whole.Root.Add(subtree); return(whole); }); return(result.ToString()); }
public System.Xml.Linq.XDocument CreateDocument() { var doc = new System.Xml.Linq.XDocument(); var root = new System.Xml.Linq.XElement("methodResponse"); doc.Add(root); var f = new System.Xml.Linq.XElement("fault"); root.Add(f); var struct_ = new XmlRpc.Struct(); struct_["faultCode"] = new XmlRpc.IntegerValue(this.FaultCode); struct_["faultString"] = new XmlRpc.StringValue(this.FaultString); struct_.AddXmlElement(f); return doc; }
public System.Xml.Linq.XDocument CreateDocument() { var doc = new System.Xml.Linq.XDocument(); var root = new System.Xml.Linq.XElement("methodResponse"); doc.Add(root); var f = new System.Xml.Linq.XElement("fault"); root.Add(f); var struct_ = new XmlRpc.Struct(); struct_["faultCode"] = new XmlRpc.IntegerValue(this.FaultCode); struct_["faultString"] = new XmlRpc.StringValue(this.FaultString); struct_.AddXmlElement(f); return(doc); }
public Data.Person Queue(string sName, string sPhone) { Data.Person dPerson = new Data.Person( ) { Id = Guid.NewGuid( ), Name = sName, Phone = sPhone }; // normally this logic would exist on the server side. if (string.IsNullOrEmpty(sName)) { throw new Exception.QueueException(Exception.QueueException.ResponseCodes.InvalidName); } else if (string.IsNullOrEmpty(sPhone)) { throw new Exception.QueueException(Exception.QueueException.ResponseCodes.InvalidPhone); } lock ( ms_oSync ) { System.Xml.Linq.XElement xWaitList = m_oXmlFilePersister.Load(mc_sStorageName) ?? new System.Xml.Linq.XElement("Waitlist"); System.Xml.Linq.XElement xPersons = GetPersons(xWaitList); if (xPersons.Elements("Person") .Select(xPerson => m_adpPersonFromXml.Adapt(xPerson)) .Any(dPersonSearch => dPersonSearch == dPerson)) { throw new Exception.QueueException(Exception.QueueException.ResponseCodes.PersonExists); } xPersons.Add(m_adpPersonToXml.Adapt(dPerson)); m_oXmlFilePersister.Save(mc_sStorageName, xWaitList); } return(dPerson); }
public static void MergeXml(System.Xml.Linq.XElement eledest, System.Xml.Linq.XElement elesrc) { foreach (var attr in elesrc.Attributes()) { eledest.SetAttributeValue(attr.Name, attr.Value); } foreach (var srcchild in elesrc.Elements()) { //var dstchild = eledest.Element(srcchild.Name); //if (dstchild != null) //{ // MergeXml(dstchild, srcchild); //} //else //{ // dstchild = new System.Xml.Linq.XElement(srcchild); // eledest.SetElementValue(srcchild.Name, dstchild); //} var dstchild = new System.Xml.Linq.XElement(srcchild); eledest.Add(dstchild); } }
private void WriteContractElementToSummary(System.Xml.Linq.XElement summaryElement, string contractElement, params string[] info) { Contract.Requires(summaryElement != null); Contract.Requires(contractElement != null); Contract.Requires(info != null); System.Text.StringBuilder infoBuilder = new System.Text.StringBuilder(contractElement); foreach (string infoString in info) { if (infoString != null) { infoBuilder.Append(" ("); infoBuilder.Append(infoString); infoBuilder.Append(")"); } } System.Xml.Linq.XName xname = "para"; System.Xml.Linq.XElement contractXElement = new System.Xml.Linq.XElement(xname, infoBuilder.ToString()); summaryElement.Add(contractXElement); Console.WriteLine("\t\t" + infoBuilder.ToString()); }
private void Save() { if (comboBoxProjects.SelectedIndex > -1) { Project project = ProjectContainer.GetInstance().ProjectList.FirstOrDefault(x => x.Name == comboBoxProjects.SelectedItem.ToString()); List <string> checkedItems = new List <string>(); foreach (var item in checkedListBoxTemplates.CheckedItems) { checkedItems.Add(item.ToString()); } project.ProjectTemplateList.RemoveAll(x => !checkedItems.Contains(x.TemplateName)); //if we unchecked a template remove it project.Name = textBoxName.Text; foreach (string templateName in checkedItems) { if (!project.ProjectTemplateList.Any(x => x.TemplateName == templateName)) //iterate the list of checked items. If we're missing a template add it. { ProjectTemplate projectTemplate = new ProjectTemplate(); projectTemplate.ScreenParameters["OutputDirectory"] = System.IO.Path.Combine(System.IO.Path.GetDirectoryName(Application.ExecutablePath), "projects", textBoxName.Text, "Output"); projectTemplate.ParametersTree = new System.Xml.Linq.XElement("parameterTree", ""); System.Xml.Linq.XElement root = new System.Xml.Linq.XElement("root"); root.SetAttributeValue("name", "root"); root.Add(new System.Xml.Linq.XElement("children")); projectTemplate.ParametersTree.Add(root); projectTemplate.TemplateName = templateName; project.ProjectTemplateList.Add(projectTemplate); } } ProjectContainer.GetInstance().UpdateProject(project); ProjectContainer.GetInstance().Save(); ProjectContainer.GetInstance().Reload(this, EventArgs.Empty); Classes.Mediation.FormMediator.GetInstance().SendMessage("Project Updated"); } }
private void SaveSettings() { System.Xml.Linq.XElement x = new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("Settings")); x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("HistoryCount"), nudHistory.Value)); x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("SlotCount"), nudSlots.Value)); x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("EmailAddress"), EmailAddress)); x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("UserName"), UserName)); x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("ServerAddress"), ServerAddress)); x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("ServerPassword"), Password)); x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("SMTPPort"), Port)); x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("EnableSSL"), enableSSL)); x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("SubjectLine"), SubjectLine)); x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("OpeningLine"), OpeningLine)); x.Add(new System.Xml.Linq.XElement(System.Xml.Linq.XName.Get("ClosingLine"), ClosingLine)); System.IO.FileInfo f = new System.IO.FileInfo("settings.xml"); if (f.Exists) f.Delete(); var str = f.Create(); var buffer = System.Text.ASCIIEncoding.ASCII.GetBytes(x.ToString()); str.Write(buffer, 0, buffer.Length); str.Close(); str.Dispose(); Properties.Settings.Default.HistoryCount = nudHistory.Value; Properties.Settings.Default.SlotCount = nudSlots.Value; Properties.Settings.Default.Save(); }
private void SavePluginOptions(string application, List<Objects.Option> options, System.Xml.Linq.XElement settingsElement) { var settingElement = new System.Xml.Linq.XElement("Setting"); var applicationAttribute = new System.Xml.Linq.XAttribute("Application", application); settingElement.Add(applicationAttribute); foreach (var option in options) { var optionElement = new System.Xml.Linq.XElement("Option"); var optionIdAttr = new System.Xml.Linq.XAttribute("Id", option.OptionId); var activeAttr = new System.Xml.Linq.XAttribute("Active", option.Active); optionElement.Add(optionIdAttr, activeAttr); if (option.Numerics != null && option.Numerics.Count > 0) { var numericsElement = new System.Xml.Linq.XElement("Numerics"); foreach (int numeric in option.Numerics) { var numericElement = new System.Xml.Linq.XElement("Numeric"); numericElement.Add(new System.Xml.Linq.XText(numeric.ToString())); numericsElement.Add(numericElement); } optionElement.Add(numericsElement); } if (option.Gestures != null && option.Gestures.Count > 0) { var gesturesElement = new System.Xml.Linq.XElement("Gestures"); foreach (int gesture in option.Gestures) { var gestureElement = new System.Xml.Linq.XElement("Gesture"); gestureElement.Add(new System.Xml.Linq.XText(gesture.ToString())); gesturesElement.Add(gestureElement); } optionElement.Add(gesturesElement); } settingElement.Add(optionElement); } settingsElement.Add(settingElement); }
public System.Xml.Linq.XElement ToXML() { System.Xml.Linq.XElement ele = new System.Xml.Linq.XElement("Service"); ele.Add(new System.Xml.Linq.XAttribute("ServiceName", this.Name)); ele.Add(new System.Xml.Linq.XAttribute("RouteSummary", this.Summary)); ele.Add(new System.Xml.Linq.XAttribute("Direction", this.Direction)); foreach (Route r in routes) ele.Add(r.ToXML()); return ele; }