public virtual bool CancelEdit() { try { if (_isBeingEdited) { _isBeingEdited = false; // destroy clone's event handler if (_editableProxy != null) { _editableProxy.Changed -= new XmlConfigurationElementEventHandler(this.OnChanged); _editableProxy = null; } // should not this accept changes? just like end edit? /// raise the AfterEdit event this.OnEditCancelled(this, new XmlConfigurationElementEventArgs(this, XmlConfigurationElementActions.None)); } return(true); } catch (Exception ex) { Debug.WriteLine(ex); } return(false); }
public virtual bool ApplyChanges(ISupportsEditing editableObject, Carbon.Configuration.SupportedEditingActions actions) { if (actions == SupportedEditingActions.None) { return(true); } XmlConfigurationElement element = editableObject as XmlConfigurationElement; if (element != null) { /// do we match in full paths? if (string.Compare(this.Fullpath, element.Fullpath, true) == 0) { /// does the element have changes, if not we don't need to bother if (element.HasChanges) { /// yes so apply it's changed features this.ElementName = element.ElementName; this.Description = element.Description; this.Category = element.Category; this.DisplayName = element.DisplayName; this.Hidden = element.Hidden; this.Readonly = element.Readonly; this.Persistent = element.Persistent; } return(true); } } return(false); }
/// <summary> /// Returns a clone of this category /// </summary> /// <returns></returns> public new XmlConfigurationCategory Clone() { XmlConfigurationCategory clone = null; XmlConfigurationElement element = (XmlConfigurationElement)base.Clone(); if (element != null) { clone = new XmlConfigurationCategory(element); clone.ResetBeforeEdit(); clone.ResetChanged(); clone.ResetAfterEdit(); clone.ResetEditCancelled(); if (_options != null) { clone.Options = (XmlConfigurationOptionCollection)_options.Clone(); } if (_categories != null) { clone.Categories = (XmlConfigurationCategoryCollection)_categories.Clone(); } } return(clone); }
public virtual bool BeginEdit() { try { if (!_isBeingEdited) { /// Raise BeforeEdit event and provide a means of cancellation XmlConfigurationElementCancelEventArgs e = new XmlConfigurationElementCancelEventArgs(this, false); this.OnBeforeEdit(this, e); if (e.Cancel) { return(false); } /// place the element in edit mode and clone ourself so that future changes will be redirected to the clone and not to ourself _editableProxy = this.GetElementToEdit(); if (_editableProxy != null) { _editableProxy.Changed += new XmlConfigurationElementEventHandler(this.OnChanged); _editableProxy._isEditableProxy = true; _isBeingEdited = true; return(true); } } } catch (Exception ex) { Debug.WriteLine(ex); } return(false); }
/// <summary> /// Initializes a new instance of the XmlConfigurationElement class /// </summary> /// <param name="element"></param> public XmlConfigurationElement(XmlConfigurationElement element) : this(element.ElementName) { _description = element.Description; _category = element.Category; _displayName = element.DisplayName; _hidden = element.Hidden; _readonly = element.Readonly; _persistent = element.Persistent; }
public virtual bool EndEdit() { bool success = false; try { if (_isBeingEdited) { _isBeingEdited = false; this.BeginInit(); // apply the changes this.ApplyChanges((ISupportsEditing)_editableProxy, SupportedEditingActions.Synchronize); this.EndInit(); // destroy clone's event handler if (_editableProxy != null) { _editableProxy.Changed -= new XmlConfigurationElementEventHandler(this.OnChanged); _editableProxy = null; } try { /// make sure to kick this off so that no we are getting all events out if (this.HasChanges) { this.OnChanged(this, new XmlConfigurationElementEventArgs(this, XmlConfigurationElementActions.Changed)); } } catch (Exception ex) { Debug.WriteLine(ex); } /// reset the haschanges flag and accept the current changes this.AcceptChanges(); } success = true; } catch (Exception ex) { Debug.WriteLine(ex); } finally { /// raise the AfterEdit event this.OnAfterEdit(this, new XmlConfigurationElementEventArgs(this, XmlConfigurationElementActions.None)); } return(success); }
/// <summary> /// Clones this configuration /// </summary> /// <returns></returns> public override object Clone() { XmlConfiguration clone = null; XmlConfigurationElement element = (XmlConfigurationElement)base.Clone(); if (element != null) { clone = new XmlConfiguration(element); clone.ResetBeforeEdit(); clone.ResetChanged(); clone.ResetAfterEdit(); clone.Path = this.Path; clone.SetHasUnpersistedChanges(this.HasUnpersistedChanges()); clone.Categories = (XmlConfigurationCategoryCollection)this.Categories.Clone(); } return(clone); }
public virtual bool ApplyToSelf(ISupportsEditing editableObject, SupportedEditingActions actions) { XmlConfigurationElement element = editableObject as XmlConfigurationElement; if (element != null) { // if this fullpath matches the element's full path, then these may apply to each other if (string.Compare(this.Fullpath, element.Fullpath, true) == 0) { if (element.HasChanges) { this.ElementName = element.ElementName; this.Description = element.Description; this.Category = element.Category; this.DisplayName = element.DisplayName; this.Hidden = element.Hidden; this.Readonly = element.Readonly; this.Persistent = element.Persistent; } return(true); } } return(false); }
public virtual bool CancelEdit() { try { if (_isBeingEdited) { _isBeingEdited = false; // destroy clone's event handler if (_editableProxy != null) { _editableProxy.Changed -= new XmlConfigurationElementEventHandler(this.OnChanged); _editableProxy = null; } // should not this accept changes? just like end edit? /// raise the AfterEdit event this.OnEditCancelled(this, new XmlConfigurationElementEventArgs(this, XmlConfigurationElementActions.None)); } return true; } catch(Exception ex) { Debug.WriteLine(ex); } return false; }
public virtual bool EndEdit() { bool success = false; try { if (_isBeingEdited) { _isBeingEdited = false; this.BeginInit(); // apply the changes this.ApplyChanges((ISupportsEditing)_editableProxy, SupportedEditingActions.Synchronize); this.EndInit(); // destroy clone's event handler if (_editableProxy != null) { _editableProxy.Changed -= new XmlConfigurationElementEventHandler(this.OnChanged); _editableProxy = null; } try { /// make sure to kick this off so that no we are getting all events out if (this.HasChanges) this.OnChanged(this, new XmlConfigurationElementEventArgs(this, XmlConfigurationElementActions.Changed)); } catch (Exception ex) { Debug.WriteLine(ex); } /// reset the haschanges flag and accept the current changes this.AcceptChanges(); } success = true; } catch(Exception ex) { Debug.WriteLine(ex); } finally { /// raise the AfterEdit event this.OnAfterEdit(this, new XmlConfigurationElementEventArgs(this, XmlConfigurationElementActions.None)); } return success; }
public virtual bool BeginEdit() { try { if (!_isBeingEdited) { /// Raise BeforeEdit event and provide a means of cancellation XmlConfigurationElementCancelEventArgs e = new XmlConfigurationElementCancelEventArgs(this, false); this.OnBeforeEdit(this, e); if (e.Cancel) return false; /// place the element in edit mode and clone ourself so that future changes will be redirected to the clone and not to ourself _editableProxy = this.GetElementToEdit(); if (_editableProxy != null) { _editableProxy.Changed += new XmlConfigurationElementEventHandler(this.OnChanged); _editableProxy._isEditableProxy = true; _isBeingEdited = true; return true; } } } catch(Exception ex) { Debug.WriteLine(ex); } return false; }
/// <summary> /// Initializes a new instance of the XmlConfigurationElementCancelEventArgs class /// </summary> /// <param name="original">The element in it's original state before changes</param> /// <param name="proposed">The element in it's proposed state after changes</param> /// <param name="cancel">A flag to indicate whether the event is cancelled</param> public XmlConfigurationElementCancelEventArgs(XmlConfigurationElement element, bool cancel) : base(cancel) { _element = element; }
/// <summary> /// Initializes a new instance of the XmlConfigurationOption class /// </summary> /// <param name="element">The element to base this option on</param> public XmlConfigurationOption(XmlConfigurationElement element) : base(element) { _valueAssemblyQualifiedName = _value.GetType().AssemblyQualifiedName; }
/// <summary> /// Initializes a new instance of the XmlConfigurationElementEventArgs class /// </summary> /// <param name="element">The element being affected by this action</param> /// <param name="action">The action affecting this element</param> public XmlConfigurationElementEventArgs(XmlConfigurationElement element, XmlConfigurationElementActions action) { _element = element; _action = action; }
/// <summary> /// Initializes a new instance of the XmlConfigurationCategory class /// </summary> public XmlConfigurationCategory(XmlConfigurationElement element) : base(element) { }
/// <summary> /// Initializes a new instance of the XmlConfigurationOption class /// </summary> /// <param name="element">The element to base this option on</param> public XmlConfiguration(XmlConfigurationElement element) : base(element) { }