/// <summary> /// Resets the comment of the configuration item, so an inherited configuration value is returned by the <see cref="Comment"/> property. /// </summary> public void ResetComment() { lock (Configuration.Sync) { if (mHasComment) { mHasComment = false; mComment = null; if (Configuration.InheritedConfiguration != null) { CascadedConfigurationItem <T> item = Configuration.InheritedConfiguration.GetItemThatHasComment <T>(mName, true); if (item != null) { OnCommentChanged(this, item.Comment); Configuration.NotifyItemCommentChanged <T>(item, item.Comment); } else { OnCommentChanged(this, null); Configuration.NotifyItemCommentChanged <T>(this, null); } } else { OnCommentChanged(this, null); Configuration.NotifyItemCommentChanged <T>(this, null); } } } }
/// <summary> /// Resets the value of the configuration item, so an inherited configuration value is returned by the <see cref="Value"/> property. /// </summary> public void ResetValue() { lock (Configuration.Sync) { if (mHasValue) { mHasValue = false; mValue = default(T); if (Configuration.InheritedConfiguration != null) { CascadedConfigurationItem <T> item = Configuration.InheritedConfiguration.GetItemThatHasValue <T>(mName, true); if (item != null) { OnValueChanged(this, item.Value); Configuration.NotifyItemValueChanged <T>(item, item.Value); } else { throw new ConfigurationException( "Configuration item does not inherit a value from some other configuration (configuration: {0}, item: {1}, type: {2}).", Configuration.Name, mName, typeof(T).FullName); } } else { throw new ConfigurationException( "Configuration item does not inherit a value from from other configuration (configuration: {0}, item: {1}, type: {2}).", Configuration.Name, mName, typeof(T).FullName); } } } }
/// <summary> /// Raises the <see cref="CommentChanged"/> event. /// </summary> /// <param name="issuer">Issuer of the event notification.</param> /// <param name="newComment">The new value.</param> protected internal virtual void OnCommentChanged(CascadedConfigurationItem <T> issuer, string newComment) { EventHandler <CommentChangedEventArgs> handler = CommentChanged; if (handler != null) { handler(this, new CommentChangedEventArgs(issuer, newComment)); } }
/// <summary> /// Raises the <see cref="ValueChanged"/> event. /// </summary> /// <param name="issuer">Issuer of the event notification.</param> /// <param name="newValue">The new value.</param> protected internal virtual void OnValueChanged(CascadedConfigurationItem <T> issuer, T newValue) { EventHandler <ValueChangedEventArgs> handler = ValueChanged; if (handler != null) { handler(this, new ValueChangedEventArgs(issuer, newValue)); } }
/// <summary> /// Initializes a new instance of the <see cref="ValueChangedEventArgs"/> class. /// </summary> /// <param name="issuer">The configuration item that has changed.</param> /// <param name="newValue">New value of the configuration item.</param> public ValueChangedEventArgs(CascadedConfigurationItem <T> issuer, T newValue) { Issuer = issuer; NewValue = newValue; }
/// <summary> /// Initializes a new instance of the <see cref="CommentChangedEventArgs"/> class. /// </summary> /// <param name="issuer">The configuration item whose comment has changed.</param> /// <param name="newComment">New comment of the configuration item.</param> public CommentChangedEventArgs(CascadedConfigurationItem <T> issuer, string newComment) { Issuer = issuer; NewComment = newComment; }