Esempio n. 1
0
        public String Get(Configuration.ConfFolder folder, Configuration.ConfEntry entry, String defaultValue)
        {
            String result = defaultValue;
            try
            {
                using (RegistryKey regkey = this.basekey.CreateSubKey(folder.ToString()))
                {
                    object o;
                    if ((o = regkey.GetValue(entry.ToString(), defaultValue)) != null)
                    {
                        if (!String.IsNullOrEmpty(o.ToString()))
                        {
                            result = o.ToString();
                        }
                    }
                    regkey.Close();
                }
            }
            catch (Exception e)
            {
                LOG.Error("Failed to get value from registry", e);
            }

            return result;
        }
Esempio n. 2
0
        public bool Set(Configuration.ConfFolder folder, Configuration.ConfEntry entry, String value)
        {
            if (value == null)
            {
                return false;
            }

            try
            {
                using (RegistryKey regkey = this.basekey.CreateSubKey(folder.ToString()))
                {
                    regkey.SetValue(entry.ToString(), value);
                    regkey.Close();
                }
            }
            catch (Exception e)
            {
                LOG.Error("Failed to set value into registry", e);
                return false;
            }

            // Trigger
            EventHandlerTrigger.TriggerEvent<ConfigurationEventArgs>(this.onConfigurationEvent, this, new ConfigurationEventArgs(folder, entry, value));

            return true;
        }