Paradox Game Engine  v1.0.0 beta06
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros Pages
Options.cs
Go to the documentation of this file.
1 using System;
2 using System.Collections.Generic;
3 using System.Linq;
4 using System.Text;
5 using System.Reflection;
6 using System.IO;
7 using System.Xml.Serialization;
8 using System.ComponentModel;
9 
10 namespace SiliconStudio.Paradox.ConfigEditor
11 {
12  [XmlRoot(Namespace = "", IsNullable = false)]
13  public class Options
14  {
15  private string paradoxPath;
16  [XmlElement]
17  public string ParadoxPath
18  {
19  get { return paradoxPath; }
20  set
21  {
22  if (string.IsNullOrWhiteSpace(value))
23  throw new ArgumentException("Invalid 'ParadoxPath' property value");
24  paradoxPath = value;
25  }
26  }
27 
28  [XmlElement]
29  public string ParadoxConfigFilename { get; set; }
30 
31  private static readonly XmlSerializer serializer = new XmlSerializer(typeof(Options));
32 
33  public static Options Load()
34  {
35  try
36  {
37  var filename = Path.ChangeExtension(Assembly.GetEntryAssembly().Location, ".config");
38  return (Options)serializer.Deserialize(new FileStream(filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite));
39  }
40  catch
41  {
42  return null;
43  }
44  }
45 
46  public void Save()
47  {
48  var filename = Path.ChangeExtension(Assembly.GetEntryAssembly().Location, ".config");
49  serializer.Serialize(new FileStream(filename, FileMode.Create, FileAccess.Write, FileShare.ReadWrite), this);
50  }
51  }
52 }
System.IO.FileMode FileMode
Definition: ScriptSync.cs:33