Merge pull request #1758 from BarryThePenguin/lazy-configuration
sparkles: Lazy Configuration Singleton on app startup
This commit is contained in:
commit
639aa06ec2
|
@ -194,18 +194,9 @@ namespace SparkleShare {
|
||||||
bool lost_folders_path = false;
|
bool lost_folders_path = false;
|
||||||
|
|
||||||
|
|
||||||
public BaseController ()
|
public BaseController (Configuration config)
|
||||||
{
|
{
|
||||||
string app_data_path = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
|
Config = config;
|
||||||
|
|
||||||
if (InstallationInfo.OperatingSystem != OS.Windows && InstallationInfo.OperatingSystem != OS.Mac)
|
|
||||||
app_data_path = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), ".config");
|
|
||||||
|
|
||||||
string config_path = Path.Combine (app_data_path, "org.sparkleshare.SparkleShare");
|
|
||||||
|
|
||||||
Config = new Configuration (config_path, "projects.xml");
|
|
||||||
Configuration.DefaultConfiguration = Config;
|
|
||||||
|
|
||||||
FoldersPath = Config.FoldersPath;
|
FoldersPath = Config.FoldersPath;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -62,7 +62,7 @@ namespace SparkleShare {
|
||||||
|
|
||||||
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
|
AppDomain.CurrentDomain.UnhandledException += OnUnhandledException;
|
||||||
|
|
||||||
Controller = new Controller ();
|
Controller = new Controller (Configuration.DefaultConfiguration);
|
||||||
Controller.Initialize ();
|
Controller.Initialize ();
|
||||||
|
|
||||||
UI = new UserInterface ();
|
UI = new UserInterface ();
|
||||||
|
|
|
@ -28,7 +28,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public class Controller : BaseController {
|
public class Controller : BaseController {
|
||||||
|
|
||||||
public Controller ()
|
public Controller (Configuration config)
|
||||||
|
: base (config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -39,7 +39,8 @@ namespace SparkleShare {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public Controller ()
|
public Controller (Configuration config)
|
||||||
|
: base (config)
|
||||||
{
|
{
|
||||||
NSApplication.Init ();
|
NSApplication.Init ();
|
||||||
|
|
||||||
|
|
|
@ -31,7 +31,8 @@ namespace SparkleShare {
|
||||||
|
|
||||||
public class Controller : BaseController {
|
public class Controller : BaseController {
|
||||||
|
|
||||||
public Controller ()
|
public Controller (Configuration config)
|
||||||
|
: base (config)
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -24,7 +24,18 @@ namespace Sparkles {
|
||||||
|
|
||||||
public class Configuration : XmlDocument {
|
public class Configuration : XmlDocument {
|
||||||
|
|
||||||
public static Configuration DefaultConfiguration;
|
private static Lazy<Configuration> ConfigLazy = new Lazy<Configuration> (() => {
|
||||||
|
string app_data_path = Environment.GetFolderPath (Environment.SpecialFolder.ApplicationData);
|
||||||
|
|
||||||
|
if (InstallationInfo.OperatingSystem != OS.Windows && InstallationInfo.OperatingSystem != OS.Mac)
|
||||||
|
app_data_path = Path.Combine (Environment.GetFolderPath (Environment.SpecialFolder.Personal), ".config");
|
||||||
|
|
||||||
|
string config_path = Path.Combine (app_data_path, "org.sparkleshare.SparkleShare");
|
||||||
|
|
||||||
|
return new Configuration (config_path, "projects.xml");
|
||||||
|
});
|
||||||
|
|
||||||
|
public static Configuration DefaultConfiguration { get { return ConfigLazy.Value; } }
|
||||||
public static bool DebugMode = true;
|
public static bool DebugMode = true;
|
||||||
|
|
||||||
public readonly string DirectoryPath;
|
public readonly string DirectoryPath;
|
||||||
|
|
Loading…
Reference in a new issue