/// <summary> /// Initializes a new instance of SettingsManager. /// </summary> public SettingsManager() { this.settingsFolder = WsapmTools.GetCommonApplicationDataFolder(); this.settingsFile = WsapmTools.GetCommonApplicationDataFile(); this.serializer = new XmlSerializer(typeof(WsapmSettings)); InitFileSystemWatcher(); }
/// <summary> /// Initializes a new instance of ServiceLog. /// </summary> /// <param name="logMode">The LogMode defining the level of detail of the log.</param> /// <param name="maxFileSize">The max file size in byte.</param> private WsapmLog(LogMode logMode, uint maxFileSize) { this.settingsFolder = WsapmTools.GetCommonApplicationDataFolder(); this.logFile = WsapmTools.GetCommonApplicationLogFile(); this.LogMode = logMode; this.MaxLogFileSize = maxFileSize; }
public TemporaryUptimeManager() { this.settingsFolder = WsapmTools.GetCommonApplicationDataFolder(); this.temporaryUptimeFile = WsapmTools.GetTemporaryUptimeFile(); this.serializer = new XmlSerializer(typeof(TemporaryUptime)); InitFileSystemWatcher(); }
/// <summary> /// Deletes the settings from the computer. /// </summary> public void DeleteSettings() { if (!WsapmTools.SettingsAvailable()) { return; } try { Directory.Delete(WsapmTools.GetCommonApplicationDataFolder(), true); } catch (Exception ex) { throw new WsapmException(Resources.Wsapm_Core.SettingsManager_DeleteSettingsError, ex); } this.LoadSettings(); }
/// <summary> /// Loads the temporary uptime. /// </summary> /// <returns></returns> public TemporaryUptime LoadTemporaryUptime() { try { if (!Directory.Exists(WsapmTools.GetCommonApplicationDataFolder()) || !File.Exists(this.temporaryUptimeFile)) { return(null); } using (FileStream fs = new FileStream(this.temporaryUptimeFile, FileMode.Open, FileAccess.Read)) { TemporaryUptime temporaryUptime = this.serializer.Deserialize(fs) as TemporaryUptime; return(temporaryUptime); } } catch (IOException ex) { throw new WsapmException(Resources.Wsapm_Core.TemporaryUptimeManager_LoadTemporaryUptimeError, ex); } }
/// <summary> /// Loads settings from settings file. /// </summary> /// <returns>The loaded settings.</returns> public WsapmSettings LoadSettings() { try { if (!Directory.Exists(WsapmTools.GetCommonApplicationDataFolder()) || !File.Exists(this.settingsFile)) { var newSetings = GetDefaultSettings(); return(newSetings); } using (FileStream fs = new FileStream(this.settingsFile, FileMode.Open, FileAccess.Read)) { WsapmSettings settings = this.serializer.Deserialize(fs) as WsapmSettings; return(settings); } } catch (IOException ex) { throw new WsapmException(Resources.Wsapm_Core.SettingsManager_LoadSettingsError, ex); } }
/// <summary> /// Returns true if setting are saved on the computer. /// </summary> /// <returns>True if settings are available, otherwise false.</returns> public static bool SettingsAvailable() { return(Directory.Exists(WsapmTools.GetCommonApplicationDataFolder())); }