fix: mark FeedbackBase default constructor as obsolete

There are situations now where feedbacks in the feedback collection
can be used to update things on UIs. If the feedback doesn't have a key, it can't
be used for this purpose.
This commit is contained in:
Andrew Welker
2025-07-25 09:18:22 -05:00
parent f0af9f8d19
commit dc7f99e176
4 changed files with 59 additions and 47 deletions

View File

@@ -42,6 +42,7 @@ namespace PepperDash.Essentials.Core
/// it will NOT reflect an actual value from a device until <seealso cref="FireUpdate"/> has been called /// it will NOT reflect an actual value from a device until <seealso cref="FireUpdate"/> has been called
/// </remarks> /// </remarks>
/// <param name="valueFunc">Delegate to invoke when this feedback needs to be updated</param> /// <param name="valueFunc">Delegate to invoke when this feedback needs to be updated</param>
[Obsolete("use constructor with Key parameter. This constructor will be removed in a future version")]
public BoolFeedback(Func<bool> valueFunc) public BoolFeedback(Func<bool> valueFunc)
: this(null, valueFunc) : this(null, valueFunc)
{ {

View File

@@ -9,45 +9,54 @@ using PepperDash.Core;
namespace PepperDash.Essentials.Core namespace PepperDash.Essentials.Core
{ {
public abstract class Feedback : IKeyed /// <summary>
{ /// Base class for all feedback types
public event EventHandler<FeedbackEventArgs> OutputChange; /// </summary>
public abstract class Feedback : IKeyed
{
/// <summary>
/// Occurs when the output value changes
/// </summary>
public event EventHandler<FeedbackEventArgs> OutputChange;
/// <summary> /// <summary>
/// Gets or sets the Key /// Gets or sets the Key
/// </summary> /// </summary>
public string Key { get; private set; } public string Key { get; private set; }
/// <summary> /// <summary>
/// Gets or sets the BoolValue /// Gets or sets the BoolValue
/// </summary> /// </summary>
/// <inheritdoc /> /// <inheritdoc />
public virtual bool BoolValue { get { return false; } } public virtual bool BoolValue { get { return false; } }
/// <summary> /// <summary>
/// Gets or sets the IntValue /// Gets or sets the IntValue
/// </summary> /// </summary>
public virtual int IntValue { get { return 0; } } public virtual int IntValue { get { return 0; } }
/// <summary> /// <summary>
/// Gets or sets the StringValue /// Gets or sets the StringValue
/// </summary> /// </summary>
public virtual string StringValue { get { return ""; } } public virtual string StringValue { get { return ""; } }
/// <summary> /// <summary>
/// Gets or sets the SerialValue /// Gets or sets the SerialValue
/// </summary> /// </summary>
public virtual string SerialValue { get { return ""; } } public virtual string SerialValue { get { return ""; } }
/// <summary> /// <summary>
/// Gets or sets the InTestMode /// Gets or sets the InTestMode
/// </summary> /// </summary>
public bool InTestMode { get; protected set; } public bool InTestMode { get; protected set; }
/// <summary> /// <summary>
/// Base Constructor - empty /// Base Constructor - empty
/// </summary> /// </summary>
protected Feedback() [Obsolete("use constructor with Key parameter. This constructor will be removed in a future version")]
{ protected Feedback() : this(null) { }
}
/// <summary>
/// Constructor with Key parameter
/// </summary>
/// <param name="key">The key for the feedback</param>
protected Feedback(string key) protected Feedback(string key)
{ {
if (key == null) if (key == null)
@@ -58,27 +67,27 @@ namespace PepperDash.Essentials.Core
/// <summary> /// <summary>
/// ClearTestValue method /// ClearTestValue method
/// </summary> /// </summary>
public void ClearTestValue() public void ClearTestValue()
{ {
InTestMode = false; InTestMode = false;
FireUpdate(); FireUpdate();
} }
/// <summary> /// <summary>
/// Fires an update synchronously /// Fires an update synchronously
/// </summary> /// </summary>
public abstract void FireUpdate(); public abstract void FireUpdate();
/// <summary> /// <summary>
/// Fires the update asynchronously within a CrestronInvoke /// Fires the update asynchronously within a CrestronInvoke
/// </summary> /// </summary>
public void InvokeFireUpdate() public void InvokeFireUpdate()
{ {
CrestronInvoke.BeginInvoke(o => FireUpdate()); CrestronInvoke.BeginInvoke(o => FireUpdate());
} }
/// <summary> /// <summary>
/// Helper method that fires event. Use this intstead of calling OutputChange /// Helper method that fires event. Use this intstead of calling OutputChange
@@ -103,5 +112,5 @@ namespace PepperDash.Essentials.Core
{ {
if (OutputChange != null) OutputChange(this, new FeedbackEventArgs(value)); if (OutputChange != null) OutputChange(this, new FeedbackEventArgs(value));
} }
} }
} }

View File

@@ -13,7 +13,7 @@ namespace PepperDash.Essentials.Core
/// </summary> /// </summary>
public class SerialFeedback : Feedback public class SerialFeedback : Feedback
{ {
public override string SerialValue { get { return _SerialValue; } } public override string SerialValue { get { return _SerialValue; } }
string _SerialValue; string _SerialValue;
//public override eCueType Type { get { return eCueType.Serial; } } //public override eCueType Type { get { return eCueType.Serial; } }
@@ -25,6 +25,7 @@ namespace PepperDash.Essentials.Core
List<StringInputSig> LinkedInputSigs = new List<StringInputSig>(); List<StringInputSig> LinkedInputSigs = new List<StringInputSig>();
[Obsolete("use constructor with Key parameter. This constructor will be removed in a future version")]
public SerialFeedback() public SerialFeedback()
{ {
} }

View File

@@ -38,6 +38,7 @@ namespace PepperDash.Essentials.Core
/// it will NOT reflect an actual value from a device until <seealso cref="FireUpdate"/> has been called /// it will NOT reflect an actual value from a device until <seealso cref="FireUpdate"/> has been called
/// </remarks> /// </remarks>
/// <param name="valueFunc">Delegate to invoke when this feedback needs to be updated</param> /// <param name="valueFunc">Delegate to invoke when this feedback needs to be updated</param>
[Obsolete("use constructor with Key parameter. This constructor will be removed in a future version")]
public StringFeedback(Func<string> valueFunc) public StringFeedback(Func<string> valueFunc)
: this(null, valueFunc) : this(null, valueFunc)
{ {