コード例 #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);
        }
コード例 #2
0
        public String Get(Configuration.ConfFolder folder, Configuration.ConfEntry entry, String defaultValue)
        {
            String result = defaultValue;

            try
            {
                lock (this.sections)
                {
                    XmlSection section = this.sections.FirstOrDefault((x) => String.Equals(x.Name, folder.ToString()));
                    if (section != null)
                    {
                        XmlSectionEntry sectionEntry = section.Entries.FirstOrDefault((x) => String.Equals(x.Key, entry.ToString()));
                        if (sectionEntry != null)
                        {
                            result = sectionEntry.Value;
                        }
                    }
                }
            }
            catch (Exception e)
            {
                LOG.Error(e);
            }

            return(result);
        }
コード例 #3
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);
        }
コード例 #4
0
        public int Get(Configuration.ConfFolder folder, Configuration.ConfEntry entry, int defaultValue)
        {
            int    result = defaultValue;
            String value  = this.Get(folder, entry, defaultValue.ToString());

            if (Int32.TryParse(value, out result))
            {
                return(result);
            }
            return(defaultValue);
        }
コード例 #5
0
        public bool InternalSet(Configuration.ConfFolder folder, Configuration.ConfEntry entry, object value)
        {
            lock (this)
            {
                IsolatedStorageSettings.ApplicationSettings[BuildKey(folder, entry)] = value;
                EventHandlerTrigger.TriggerEvent <ConfigurationEventArgs>(this.onConfigurationEvent, this, new ConfigurationEventArgs(folder, entry, value));

                this.DeferredSave();
                return(true);
            }
        }
コード例 #6
0
 public int Get(Configuration.ConfFolder folder, Configuration.ConfEntry entry, int defaultValue)
 {
     lock (this)
     {
         if (mDeferredSaveTimer.IsEnabled)
         {
             this.ImmediateSave();
         }
         int value;
         if (!IsolatedStorageSettings.ApplicationSettings.TryGetValue(BuildKey(folder, entry), out value))
         {
             value = defaultValue;
         }
         return(value);
     }
 }
コード例 #7
0
        public int Get(Configuration.ConfFolder folder, Configuration.ConfEntry entry, int defaultValue)
        {
            int    result = defaultValue;
            string value  = this.Get(folder, entry, defaultValue.ToString());
            int    result2;

            if (int.TryParse(value, out result))
            {
                result2 = result;
            }
            else
            {
                result2 = defaultValue;
            }
            return(result2);
        }
コード例 #8
0
        public bool Set(Configuration.ConfFolder folder, Configuration.ConfEntry entry, string value)
        {
            bool result;

            if (value == null)
            {
                result = false;
            }
            else
            {
                try
                {
                    lock (this.sections)
                    {
                        ConfigurationService.XmlSection section = this.sections.FirstOrDefault((ConfigurationService.XmlSection x) => string.Equals(x.Name, folder.ToString()));
                        if (section == null)
                        {
                            section = new ConfigurationService.XmlSection(folder.ToString());
                            this.sections.Add(section);
                        }
                        ConfigurationService.XmlSectionEntry sectionEntry = section.Entries.FirstOrDefault((ConfigurationService.XmlSectionEntry x) => string.Equals(x.Key, entry.ToString()));
                        if (sectionEntry == null)
                        {
                            sectionEntry = new ConfigurationService.XmlSectionEntry(entry.ToString(), value);
                            section.Entries.Add(sectionEntry);
                        }
                        else
                        {
                            sectionEntry.Value = value;
                        }
                    }
                }
                catch (System.Exception e)
                {
                    ConfigurationService.LOG.Error("Failed to set value into registry", e);
                    result = false;
                    return(result);
                }
                EventHandlerTrigger.TriggerEvent <ConfigurationEventArgs>(this.onConfigurationEvent, this, new ConfigurationEventArgs(folder, entry, value));
                this.DeferredSave();
                result = true;
            }
            return(result);
        }
コード例 #9
0
        public bool Set(Configuration.ConfFolder folder, Configuration.ConfEntry entry, String value)
        {
            if (value == null)
            {
                return(false);
            }

            try
            {
                lock (this.sections)
                {
                    XmlSection section = this.sections.FirstOrDefault((x) => String.Equals(x.Name, folder.ToString()));
                    if (section == null)
                    {
                        section = new XmlSection(folder.ToString());
                        this.sections.Add(section);
                    }

                    XmlSectionEntry sectionEntry = section.Entries.FirstOrDefault((x) => String.Equals(x.Key, entry.ToString()));
                    if (sectionEntry == null)
                    {
                        sectionEntry = new XmlSectionEntry(entry.ToString(), value);
                        section.Entries.Add(sectionEntry);
                    }
                    else
                    {
                        sectionEntry.Value = value;
                    }
                }
            }
            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));

            this.DeferredSave();

            return(true);
        }
コード例 #10
0
 public bool Set(Configuration.ConfFolder folder, Configuration.ConfEntry entry, bool value)
 {
     return(this.Set(folder, entry, value ? Boolean.TrueString : Boolean.FalseString));
 }
コード例 #11
0
 public bool Get(Configuration.ConfFolder folder, Configuration.ConfEntry entry, bool defaultValue)
 {
     return(Convert.ToBoolean(this.Get(folder, entry, defaultValue ? Boolean.TrueString : Boolean.FalseString)));
 }
コード例 #12
0
 public bool Set(Configuration.ConfFolder folder, Configuration.ConfEntry entry, int value)
 {
     return(this.Set(folder, entry, value.ToString()));
 }
コード例 #13
0
 public ConfigurationEventArgs(Configuration.ConfSection section, Configuration.ConfEntry entry, object value)
 {
     this.section = section;
     this.entry = entry;
     this.value = value;
 }
コード例 #14
0
 public bool Set(Configuration.ConfFolder folder, Configuration.ConfEntry entry, String value)
 {
     return(InternalSet(folder, entry, value));
 }
コード例 #15
0
 String BuildKey(Configuration.ConfFolder folder, Configuration.ConfEntry entry)
 {
     return(String.Format("{0}/{1}", folder, entry));
 }
コード例 #16
0
ファイル: ConfigurationEventArgs.cs プロジェクト: zzh56/boghe
 public ConfigurationEventArgs(Configuration.ConfFolder folder, Configuration.ConfEntry entry, object value)
 {
     this.folder = folder;
     this.entry  = entry;
     this.value  = value;
 }
コード例 #17
0
 public ConfigurationEventArgs(Configuration.ConfSection section, Configuration.ConfEntry entry, object value)
 {
     this.section = section;
     this.entry   = entry;
     this.value   = value;
 }
コード例 #18
0
 public ConfigurationEventArgs(Configuration.ConfFolder folder, Configuration.ConfEntry entry, object value)
 {
     this.folder = folder;
     this.entry = entry;
     this.value = value;
 }