2 using System.Collections.Generic;
5 using System.Xml.Serialization;
29 FileInfo PluginAssemblyFileInfo =
new FileInfo(Assembly.GetExecutingAssembly().Location);
30 return PluginAssemblyFileInfo.FullName.Substring(0, PluginAssemblyFileInfo.FullName.Length - PluginAssemblyFileInfo.Extension.Length) +
".xml";
41 using (MemoryStream ms =
new MemoryStream())
43 new XmlSerializer(typeof(
Config)).Serialize(ms,
this);
45 using (StreamReader sr =
new StreamReader(ms, Encoding.Default))
68 tw =
new StreamWriter((FileName == null ?
ConfigFileName : FileName),
false);
79 throw new Exception(
"Could not save PinballX DirectOutput Plugin config to " + (FileName == null ?
ConfigFileName : FileName), e);
98 using (StreamReader streamReader =
new StreamReader((FileName==null?
ConfigFileName:FileName)))
100 Xml = streamReader.ReadToEnd();
101 streamReader.Close();
106 throw new Exception(
"Could not read PinballX DirectOutput Plugin config file" + (FileName == null ?
ConfigFileName : FileName), E);
121 byte[] xmlBytes = Encoding.Default.GetBytes(ConfigXml);
122 using (MemoryStream ms =
new MemoryStream(xmlBytes))
126 return (
Config)
new XmlSerializer(typeof(
Config)).Deserialize(ms);
131 Exception Ex =
new Exception(
"Could not deserialize the PinballX DirectOutput Plugin config from XML data.", E);
132 Ex.Data.Add(
"XML Data", ConfigXml);
string GetConfigXml()
Returns a serialized XML representation of the configuration.
static Config GetConfigFromXml(string ConfigXml)
Instanciates a Cabinet object from a cabinet configuration in a XML string.
static Config GetConfigFromXmlFile(string FileName=null)
Instanciates a config object from a cabinet configuration in a XML file.
static string ConfigFileName
void SaveConfigXmlFile(string FileName=null)
Serializes the configuration to a XML file.