示例#1
0
 private void LoadConfig()
 {
     if (!File.Exists(Path.Combine(GameStorePath.gamepathconfig, filename)))
     {
         Console.WriteLine(server.language.ServerMonitorConfigNotFound());
         SaveConfig();
     }
     else
     {
         try
         {
             using (TextReader textReader = new StreamReader(Path.Combine(GameStorePath.gamepathconfig, filename)))
             {
                 XmlSerializer deserializer = new XmlSerializer(typeof(ServerMonitorConfig));
                 this.config = (ServerMonitorConfig)deserializer.Deserialize(textReader);
                 textReader.Close();
                 SaveConfig();
             }
         }
         catch //This if for the original format
         {
             using (Stream s = new MemoryStream(File.ReadAllBytes(Path.Combine(GameStorePath.gamepathconfig, filename))))
             {
                 this.config = new ServerMonitorConfig();
                 StreamReader sr = new StreamReader(s);
                 XmlDocument  d  = new XmlDocument();
                 d.Load(sr);
             }
             //Save with new version.
             SaveConfig();
         }
     }
     Console.WriteLine(server.language.ServerMonitorConfigLoaded());
 }
示例#2
0
    public void SaveConfig()
    {
        //Verify that we have a directory to place the file into.
        if (!Directory.Exists(GameStorePath.gamepathconfig))
        {
            Directory.CreateDirectory(GameStorePath.gamepathconfig);
        }

        XmlSerializer serializer = new XmlSerializer(typeof(ServerMonitorConfig));
        TextWriter    textWriter = new StreamWriter(Path.Combine(GameStorePath.gamepathconfig, filename));

        //Check to see if config has been initialized.
        if (this.config == null)
        {
            this.config = new ServerMonitorConfig();
        }
        //Serialize the config class to XML.
        serializer.Serialize(textWriter, this.config);
        textWriter.Close();
    }
示例#3
0
    public void SaveConfig()
    {
        //Verify that we have a directory to place the file into.
        if (!Directory.Exists(GameStorePath.gamepathconfig))
        {
            Directory.CreateDirectory(GameStorePath.gamepathconfig);
        }

        XmlSerializer serializer = new XmlSerializer(typeof(ServerMonitorConfig));
        TextWriter textWriter = new StreamWriter(Path.Combine(GameStorePath.gamepathconfig, filename));

        //Check to see if config has been initialized.
        if (this.config == null)
        {
            this.config = new ServerMonitorConfig();
        }
        //Serialize the config class to XML.
        serializer.Serialize(textWriter, this.config);
        textWriter.Close();
    }
示例#4
0
 private void LoadConfig()
 {
     if (!File.Exists(Path.Combine(GameStorePath.gamepathconfig, filename)))
     {
         Console.WriteLine(server.language.ServerMonitorConfigNotFound());
         SaveConfig();
     }
     else
     {
         try
         {
             using (TextReader textReader = new StreamReader(Path.Combine(GameStorePath.gamepathconfig, filename)))
             {
                 XmlSerializer deserializer = new XmlSerializer(typeof(ServerMonitorConfig));
                 this.config = (ServerMonitorConfig)deserializer.Deserialize(textReader);
                 textReader.Close();
                 SaveConfig();
             }
         }
         catch //This if for the original format
         {
             using (Stream s = new MemoryStream(File.ReadAllBytes(Path.Combine(GameStorePath.gamepathconfig, filename))))
             {
                 this.config = new ServerMonitorConfig();
                 StreamReader sr = new StreamReader(s);
                 XmlDocument d = new XmlDocument();
                 d.Load(sr);
             }
             //Save with new version.
             SaveConfig();
         }
     }
     Console.WriteLine(server.language.ServerMonitorConfigLoaded());
 }