public String Get(Configuration.ConfSection 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); }
public int Get(Configuration.ConfSection 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); }
private void SaveWindowLocation() { Configuration.ConfSection section = ConfSectionFromWindow(WindowType); ServiceManager.Instance.ConfigurationService.Set(section, Configuration.ConfEntry.WINDOW_LEFT, this.Left.ToString()); ServiceManager.Instance.ConfigurationService.Set(section, Configuration.ConfEntry.WINDOW_TOP, this.Top.ToString()); ServiceManager.Instance.ConfigurationService.Set(section, Configuration.ConfEntry.WINDOW_WIDTH, this.ActualWidth.ToString()); ServiceManager.Instance.ConfigurationService.Set(section, Configuration.ConfEntry.WINDOW_HEIGHT, this.ActualHeight.ToString()); }
public bool Set(Configuration.ConfSection 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(this.onConfigurationEvent, this, new ConfigurationEventArgs(folder, entry, value)); this.DeferredSave(); return(true); }
protected void Window_Initialized(object sender, EventArgs e) { Configuration.ConfSection section = ConfSectionFromWindow(WindowType); var ws = WindowState.Normal; try { var wsText = ServiceManager.Instance.ConfigurationService.Get(section, Configuration.ConfEntry.WINDOW_STATE, "Normal"); ws = (WindowState)Enum.Parse(typeof(WindowState), wsText, true); } catch (Exception ex) { Debug.WriteLine("WindowInitialized: Parse State. {0} {1} ", WindowType, ex.Message); ws = WindowState.Normal; } this.WindowState = ws; try { this.Left = Convert.ToInt32(ServiceManager.Instance.ConfigurationService.Get(section, Configuration.ConfEntry.WINDOW_LEFT, GetWindowDefaultCoordinates(WindowType).X.ToString())); } catch (FormatException) { this.Left = GetWindowDefaultCoordinates(WindowType).X; } catch (Exception ex) { Debug.WriteLine("WindowInitialized: Parse Left. {0} {1} ", WindowType, ex.Message); } try { this.Top = Convert.ToInt32(ServiceManager.Instance.ConfigurationService.Get(section, Configuration.ConfEntry.WINDOW_TOP, GetWindowDefaultCoordinates(WindowType).Y.ToString())); } catch (FormatException fe) { this.Top = GetWindowDefaultCoordinates(WindowType).Y; Debug.WriteLine("WindowInitialized: Parse Top. " + fe.Message); } catch (Exception ex) { Debug.WriteLine("WindowInitialized: Parse Top. {0} {1} ", WindowType, ex.Message); } Size defaultSize = GetWindowDefaultDimensions(WindowType); try { this.Width = Convert.ToDouble(ServiceManager.Instance.ConfigurationService.Get(section, Configuration.ConfEntry.WINDOW_WIDTH, defaultSize.Width.ToString())); } catch (Exception ex) { Debug.WriteLine("WindowInitialized: Parse Width. {0} {1} ", WindowType, ex.Message); } try { this.Height = Convert.ToDouble(ServiceManager.Instance.ConfigurationService.Get(section, Configuration.ConfEntry.WINDOW_HEIGHT, defaultSize.Height.ToString())); } catch (Exception ex) { Debug.WriteLine("WindowInitialized: Parse Height. {0} {1} ", WindowType, ex.Message); } }
protected void Window_StateChanged(object sender, EventArgs e) { Configuration.ConfSection section = ConfSectionFromWindow(WindowType); ServiceManager.Instance.ConfigurationService.Set(section, Configuration.ConfEntry.WINDOW_STATE, this.WindowState.ToString()); }
public bool Set(Configuration.ConfSection folder, Configuration.ConfEntry entry, bool value) { return(this.Set(folder, entry, value ? Boolean.TrueString : Boolean.FalseString)); }
public bool Get(Configuration.ConfSection folder, Configuration.ConfEntry entry, bool defaultValue) { return(Convert.ToBoolean(this.Get(folder, entry, defaultValue ? Boolean.TrueString : Boolean.FalseString))); }
public bool Set(Configuration.ConfSection folder, Configuration.ConfEntry entry, int value) { return(this.Set(folder, entry, value.ToString())); }
public ConfigurationEventArgs(Configuration.ConfSection section, Configuration.ConfEntry entry, object value) { this.section = section; this.entry = entry; this.value = value; }
public ConfigurationEventArgs(Configuration.ConfSection section, Configuration.ConfEntry entry, object value) { this.section = section; this.entry = entry; this.value = value; }