Exemple #1
0
        /// <summary>
        /// Constructs a service to keep track of changes to the model objects and store them in the
        /// registry
        /// </summary>
        /// <param name="toSave">The model class with values we want to save in the registry</param>
        public LoggingService()
        {
            bool bEnabled = false;
            // Check in the registry for the logging value and if it's enabled
            RegistryKey properties = Registry.CurrentUser.OpenSubKey(RegistryService.m_szRegistryString, true);

            if (properties == null)
            {
                //If this is the first time we have run the app:
                properties = Registry.CurrentUser.CreateSubKey(RegistryService.m_szRegistryString);
                bEnabled   = true;
            }

            // Check if we are enabled
            string enabled = RegistryService.GetStringRegistryValue(properties, "LoggingEnabled");

            if (enabled != null)
            {
                bEnabled = bool.Parse(enabled);
            }

            // Get the Path
            string path = RegistryService.GetStringRegistryValue(properties, "LoggingPath");

            if (path == null)
            {
                path = ".\\Logs";
            }

            if (bEnabled)
            {
                this.SetupLogFileHelper(path);
            }
        }
Exemple #2
0
 /// <summary>
 /// Returns a property that is of type string.
 /// </summary>
 /// <param name="name">The name of the property to return.</param>
 /// <returns>The string that corresponds to the specified key or null
 /// if no such key exists.</returns>
 protected string GetStringRegistryValue(string name)
 {
     return(RegistryService.GetStringRegistryValue(this.m_RegistryKey, name));
 }