mirror of
https://github.com/aaru-dps/Aaru.Server.git
synced 2025-12-16 19:24:27 +00:00
REFACTOR: All refactor in DiscImageChef.Settings.
This commit is contained in:
@@ -79,11 +79,11 @@ namespace DiscImageChef.Settings
|
|||||||
public static void LoadSettings()
|
public static void LoadSettings()
|
||||||
{
|
{
|
||||||
Current = new DicSettings();
|
Current = new DicSettings();
|
||||||
PlatformID ptID = DetectOS.GetRealPlatformID();
|
PlatformID ptId = DetectOS.GetRealPlatformID();
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
switch(ptID)
|
switch(ptId)
|
||||||
{
|
{
|
||||||
case PlatformID.MacOSX:
|
case PlatformID.MacOSX:
|
||||||
case PlatformID.iOS:
|
case PlatformID.iOS:
|
||||||
@@ -150,7 +150,7 @@ namespace DiscImageChef.Settings
|
|||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
switch(ptID)
|
switch(ptId)
|
||||||
{
|
{
|
||||||
case PlatformID.MacOSX:
|
case PlatformID.MacOSX:
|
||||||
case PlatformID.iOS:
|
case PlatformID.iOS:
|
||||||
@@ -171,56 +171,42 @@ namespace DiscImageChef.Settings
|
|||||||
NSDictionary parsedPreferences = (NSDictionary)BinaryPropertyListParser.Parse(prefsFs);
|
NSDictionary parsedPreferences = (NSDictionary)BinaryPropertyListParser.Parse(prefsFs);
|
||||||
if(parsedPreferences != null)
|
if(parsedPreferences != null)
|
||||||
{
|
{
|
||||||
NSObject obj;
|
Current.SaveReportsGlobally = parsedPreferences.TryGetValue("SaveReportsGlobally", out NSObject obj) && ((NSNumber)obj).ToBool();
|
||||||
|
|
||||||
if(parsedPreferences.TryGetValue("SaveReportsGlobally", out obj)) Current.SaveReportsGlobally = ((NSNumber)obj).ToBool();
|
Current.ShareReports = parsedPreferences.TryGetValue("ShareReports", out obj) && ((NSNumber)obj).ToBool();
|
||||||
else Current.SaveReportsGlobally = false;
|
|
||||||
|
|
||||||
if(parsedPreferences.TryGetValue("ShareReports", out obj)) Current.ShareReports = ((NSNumber)obj).ToBool();
|
|
||||||
else Current.ShareReports = false;
|
|
||||||
|
|
||||||
NSDictionary stats;
|
|
||||||
if(parsedPreferences.TryGetValue("Stats", out obj))
|
if(parsedPreferences.TryGetValue("Stats", out obj))
|
||||||
{
|
{
|
||||||
stats = (NSDictionary)obj;
|
NSDictionary stats = (NSDictionary)obj;
|
||||||
|
|
||||||
if(stats != null)
|
if(stats != null)
|
||||||
{
|
{
|
||||||
NSObject obj2;
|
Current.Stats = new StatsSettings
|
||||||
Current.Stats = new StatsSettings();
|
{
|
||||||
|
ShareStats =
|
||||||
if(stats.TryGetValue("ShareStats", out obj2)) Current.Stats.ShareStats = ((NSNumber)obj2).ToBool();
|
stats.TryGetValue("ShareStats", out NSObject obj2) &&
|
||||||
else Current.Stats.ShareStats = false;
|
((NSNumber)obj2).ToBool(),
|
||||||
|
BenchmarkStats =
|
||||||
if(stats.TryGetValue("BenchmarkStats", out obj2)) Current.Stats.BenchmarkStats = ((NSNumber)obj2).ToBool();
|
stats.TryGetValue("BenchmarkStats", out obj2) && ((NSNumber)obj2).ToBool(),
|
||||||
else Current.Stats.BenchmarkStats = false;
|
CommandStats =
|
||||||
|
stats.TryGetValue("CommandStats", out obj2) && ((NSNumber)obj2).ToBool(),
|
||||||
if(stats.TryGetValue("CommandStats", out obj2)) Current.Stats.CommandStats = ((NSNumber)obj2).ToBool();
|
DeviceStats =
|
||||||
else Current.Stats.CommandStats = false;
|
stats.TryGetValue("DeviceStats", out obj2) && ((NSNumber)obj2).ToBool(),
|
||||||
|
FilesystemStats =
|
||||||
if(stats.TryGetValue("DeviceStats", out obj2)) Current.Stats.DeviceStats = ((NSNumber)obj2).ToBool();
|
stats.TryGetValue("FilesystemStats", out obj2) && ((NSNumber)obj2).ToBool(),
|
||||||
else Current.Stats.DeviceStats = false;
|
FilterStats =
|
||||||
|
stats.TryGetValue("FilterStats", out obj2) && ((NSNumber)obj2).ToBool(),
|
||||||
if(stats.TryGetValue("FilesystemStats", out obj2)) Current.Stats.FilesystemStats = ((NSNumber)obj2).ToBool();
|
MediaImageStats =
|
||||||
else Current.Stats.FilesystemStats = false;
|
stats.TryGetValue("MediaImageStats", out obj2) && ((NSNumber)obj2).ToBool(),
|
||||||
|
MediaScanStats =
|
||||||
if(stats.TryGetValue("FilterStats", out obj2)) Current.Stats.FilterStats = ((NSNumber)obj2).ToBool();
|
stats.TryGetValue("MediaScanStats", out obj2) && ((NSNumber)obj2).ToBool(),
|
||||||
else Current.Stats.FilterStats = false;
|
PartitionStats =
|
||||||
|
stats.TryGetValue("PartitionStats", out obj2) && ((NSNumber)obj2).ToBool(),
|
||||||
if(stats.TryGetValue("MediaImageStats", out obj2)) Current.Stats.MediaImageStats = ((NSNumber)obj2).ToBool();
|
MediaStats =
|
||||||
else Current.Stats.MediaImageStats = false;
|
stats.TryGetValue("MediaStats", out obj2) && ((NSNumber)obj2).ToBool(),
|
||||||
|
VerifyStats =
|
||||||
if(stats.TryGetValue("MediaScanStats", out obj2)) Current.Stats.MediaScanStats = ((NSNumber)obj2).ToBool();
|
stats.TryGetValue("VerifyStats", out obj2) && ((NSNumber)obj2).ToBool()
|
||||||
else Current.Stats.MediaScanStats = false;
|
};
|
||||||
|
|
||||||
if(stats.TryGetValue("PartitionStats", out obj2)) Current.Stats.PartitionStats = ((NSNumber)obj2).ToBool();
|
|
||||||
else Current.Stats.PartitionStats = false;
|
|
||||||
|
|
||||||
if(stats.TryGetValue("MediaStats", out obj2)) Current.Stats.MediaStats = ((NSNumber)obj2).ToBool();
|
|
||||||
else Current.Stats.MediaStats = false;
|
|
||||||
|
|
||||||
if(stats.TryGetValue("VerifyStats", out obj2)) Current.Stats.VerifyStats = ((NSNumber)obj2).ToBool();
|
|
||||||
else Current.Stats.VerifyStats = false;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else Current.Stats = null;
|
else Current.Stats = null;
|
||||||
@@ -264,18 +250,20 @@ namespace DiscImageChef.Settings
|
|||||||
bool stats = Convert.ToBoolean(key.GetValue("Statistics"));
|
bool stats = Convert.ToBoolean(key.GetValue("Statistics"));
|
||||||
if(stats)
|
if(stats)
|
||||||
{
|
{
|
||||||
Current.Stats = new StatsSettings();
|
Current.Stats = new StatsSettings
|
||||||
Current.Stats.ShareStats = Convert.ToBoolean(key.GetValue("ShareStats"));
|
{
|
||||||
Current.Stats.BenchmarkStats = Convert.ToBoolean(key.GetValue("BenchmarkStats"));
|
ShareStats = Convert.ToBoolean(key.GetValue("ShareStats")),
|
||||||
Current.Stats.CommandStats = Convert.ToBoolean(key.GetValue("CommandStats"));
|
BenchmarkStats = Convert.ToBoolean(key.GetValue("BenchmarkStats")),
|
||||||
Current.Stats.DeviceStats = Convert.ToBoolean(key.GetValue("DeviceStats"));
|
CommandStats = Convert.ToBoolean(key.GetValue("CommandStats")),
|
||||||
Current.Stats.FilesystemStats = Convert.ToBoolean(key.GetValue("FilesystemStats"));
|
DeviceStats = Convert.ToBoolean(key.GetValue("DeviceStats")),
|
||||||
Current.Stats.FilterStats = Convert.ToBoolean(key.GetValue("FilterStats"));
|
FilesystemStats = Convert.ToBoolean(key.GetValue("FilesystemStats")),
|
||||||
Current.Stats.MediaImageStats = Convert.ToBoolean(key.GetValue("MediaImageStats"));
|
FilterStats = Convert.ToBoolean(key.GetValue("FilterStats")),
|
||||||
Current.Stats.MediaScanStats = Convert.ToBoolean(key.GetValue("MediaScanStats"));
|
MediaImageStats = Convert.ToBoolean(key.GetValue("MediaImageStats")),
|
||||||
Current.Stats.PartitionStats = Convert.ToBoolean(key.GetValue("PartitionStats"));
|
MediaScanStats = Convert.ToBoolean(key.GetValue("MediaScanStats")),
|
||||||
Current.Stats.MediaStats = Convert.ToBoolean(key.GetValue("MediaStats"));
|
PartitionStats = Convert.ToBoolean(key.GetValue("PartitionStats")),
|
||||||
Current.Stats.VerifyStats = Convert.ToBoolean(key.GetValue("VerifyStats"));
|
MediaStats = Convert.ToBoolean(key.GetValue("MediaStats")),
|
||||||
|
VerifyStats = Convert.ToBoolean(key.GetValue("VerifyStats"))
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -303,8 +291,8 @@ namespace DiscImageChef.Settings
|
|||||||
}
|
}
|
||||||
catch
|
catch
|
||||||
{
|
{
|
||||||
if(prefsFs != null) prefsFs.Close();
|
prefsFs?.Close();
|
||||||
if(prefsSr != null) prefsSr.Close();
|
prefsSr?.Close();
|
||||||
SetDefaultSettings();
|
SetDefaultSettings();
|
||||||
SaveSettings();
|
SaveSettings();
|
||||||
}
|
}
|
||||||
@@ -314,30 +302,34 @@ namespace DiscImageChef.Settings
|
|||||||
{
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
PlatformID ptID = DetectOS.GetRealPlatformID();
|
PlatformID ptId = DetectOS.GetRealPlatformID();
|
||||||
|
|
||||||
switch(ptID)
|
switch(ptId)
|
||||||
{
|
{
|
||||||
case PlatformID.MacOSX:
|
case PlatformID.MacOSX:
|
||||||
case PlatformID.iOS:
|
case PlatformID.iOS:
|
||||||
{
|
{
|
||||||
NSDictionary root = new NSDictionary();
|
NSDictionary root = new NSDictionary
|
||||||
root.Add("SaveReportsGlobally", Current.SaveReportsGlobally);
|
{
|
||||||
root.Add("ShareReports", Current.ShareReports);
|
{"SaveReportsGlobally", Current.SaveReportsGlobally},
|
||||||
|
{"ShareReports", Current.ShareReports}
|
||||||
|
};
|
||||||
if(Current.Stats != null)
|
if(Current.Stats != null)
|
||||||
{
|
{
|
||||||
NSDictionary stats = new NSDictionary();
|
NSDictionary stats = new NSDictionary
|
||||||
stats.Add("ShareStats", Current.Stats.ShareStats);
|
{
|
||||||
stats.Add("BenchmarkStats", Current.Stats.BenchmarkStats);
|
{"ShareStats", Current.Stats.ShareStats},
|
||||||
stats.Add("CommandStats", Current.Stats.CommandStats);
|
{"BenchmarkStats", Current.Stats.BenchmarkStats},
|
||||||
stats.Add("DeviceStats", Current.Stats.DeviceStats);
|
{"CommandStats", Current.Stats.CommandStats},
|
||||||
stats.Add("FilesystemStats", Current.Stats.FilesystemStats);
|
{"DeviceStats", Current.Stats.DeviceStats},
|
||||||
stats.Add("FilterStats", Current.Stats.FilterStats);
|
{"FilesystemStats", Current.Stats.FilesystemStats},
|
||||||
stats.Add("MediaImageStats", Current.Stats.MediaImageStats);
|
{"FilterStats", Current.Stats.FilterStats},
|
||||||
stats.Add("MediaScanStats", Current.Stats.MediaScanStats);
|
{"MediaImageStats", Current.Stats.MediaImageStats},
|
||||||
stats.Add("PartitionStats", Current.Stats.PartitionStats);
|
{"MediaScanStats", Current.Stats.MediaScanStats},
|
||||||
stats.Add("MediaStats", Current.Stats.MediaStats);
|
{"PartitionStats", Current.Stats.PartitionStats},
|
||||||
stats.Add("VerifyStats", Current.Stats.VerifyStats);
|
{"MediaStats", Current.Stats.MediaStats},
|
||||||
|
{"VerifyStats", Current.Stats.VerifyStats}
|
||||||
|
};
|
||||||
root.Add("Stats", stats);
|
root.Add("Stats", stats);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -415,27 +407,32 @@ namespace DiscImageChef.Settings
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
#pragma warning disable RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||||
catch { }
|
catch { // ignored
|
||||||
|
}
|
||||||
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
|
#pragma warning restore RECS0022 // A catch clause that catches System.Exception and has an empty body
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void SetDefaultSettings()
|
static void SetDefaultSettings()
|
||||||
{
|
{
|
||||||
Current = new DicSettings();
|
Current = new DicSettings
|
||||||
Current.SaveReportsGlobally = true;
|
{
|
||||||
Current.ShareReports = true;
|
SaveReportsGlobally = true,
|
||||||
Current.Stats = new StatsSettings();
|
ShareReports = true,
|
||||||
Current.Stats.BenchmarkStats = true;
|
Stats = new StatsSettings
|
||||||
Current.Stats.CommandStats = true;
|
{
|
||||||
Current.Stats.DeviceStats = true;
|
BenchmarkStats = true,
|
||||||
Current.Stats.FilesystemStats = true;
|
CommandStats = true,
|
||||||
Current.Stats.MediaImageStats = true;
|
DeviceStats = true,
|
||||||
Current.Stats.MediaScanStats = true;
|
FilesystemStats = true,
|
||||||
Current.Stats.FilterStats = true;
|
MediaImageStats = true,
|
||||||
Current.Stats.MediaStats = true;
|
MediaScanStats = true,
|
||||||
Current.Stats.PartitionStats = true;
|
FilterStats = true,
|
||||||
Current.Stats.ShareStats = true;
|
MediaStats = true,
|
||||||
Current.Stats.VerifyStats = true;
|
PartitionStats = true,
|
||||||
|
ShareStats = true,
|
||||||
|
VerifyStats = true
|
||||||
|
}
|
||||||
|
};
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in New Issue
Block a user