示例#1
0
 /// <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();
 }
示例#2
0
 /// <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;
 }
示例#3
0
 public TemporaryUptimeManager()
 {
     this.settingsFolder      = WsapmTools.GetCommonApplicationDataFolder();
     this.temporaryUptimeFile = WsapmTools.GetTemporaryUptimeFile();
     this.serializer          = new XmlSerializer(typeof(TemporaryUptime));
     InitFileSystemWatcher();
 }
示例#4
0
        /// <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();
        }
示例#5
0
        /// <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);
            }
        }
示例#6
0
        /// <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);
            }
        }
示例#7
0
 /// <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()));
 }