-
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
137 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
<Settings> | ||
<Java.List>null</Java.List> | ||
</Settings> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using System.Text; | ||
using System.Threading.Tasks; | ||
using System.Xml; | ||
|
||
namespace SodaCL.Toolkits { | ||
|
||
internal class XmlTool { | ||
private XmlNodeList _nodes; | ||
private XmlDocument doc; | ||
|
||
public XmlTool(string path) { | ||
try { | ||
doc = new XmlDocument(); | ||
doc.Load(path); | ||
_nodes = doc.DocumentElement.ChildNodes; | ||
} | ||
catch (XmlException ex) { | ||
Logger.Log(false, Logger.ModuleList.IO, Logger.LogInfo.Error, null, ex); | ||
throw ex; | ||
} | ||
} | ||
|
||
public void CreateNode(string nodeName) { | ||
var root = doc.CreateElement(nodeName); | ||
doc.AppendChild(root); | ||
} | ||
|
||
public string GetNodeValue(string nodeName) { | ||
foreach (var node in _nodes) { | ||
if (node is XmlElement element) { | ||
if (element.Name == nodeName) { | ||
return element.InnerText; | ||
} | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
public void SetNodeValue(string nodeName, string value) { | ||
foreach (XmlNode node in _nodes) { | ||
if (node.Name == nodeName) { | ||
node.InnerText = value; | ||
doc.Save(Launcher.LauncherInfo.SODACL_SETTINGS); | ||
return; | ||
} | ||
} | ||
} | ||
} | ||
} |