Files
DP44/Common/DTS.Common.Utilities/UpdateNotifyingList.cs

66 lines
1.9 KiB
C#
Raw Permalink Normal View History

2026-04-17 14:55:32 -04:00
/*
* UpdateNotifyingList.cs
*
* Copyright © 2009
* Diversified Technical Systems, Inc.
* All Rights Reserved
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using DTS.Common.Utilities.DotNetProgrammingConstructs;
namespace DTS.Common.Utilities
{
public class UpdateNotifyingList<T> : Exceptional
{
/// <summary>
/// Initialize an instance of the UpdateNotifyingList class.
/// </summary>
public UpdateNotifyingList()
{
}
/// <summary>
/// Get/set the notification-bound items in this list.
/// </summary>
public List<T> Items
{
get => _Items.Value;
set
{
try
{ //
// Update list items and then notify all subscribers.
//
_Items.Value = value;
OnUpdate(value);
}
catch (System.Exception ex)
{
throw new UpdateNotifyingList<T>.Exception("encountered problem setting UpdateNotifyingList.Items", ex);
}
}
}
private Property<List<T>> _Items
= new Property<List<T>>("NotifyingList", null, false);
/// <summary>
/// Callback method to be invoked whenever the notifying list is updated.
/// </summary>
///
/// <param name="updatedContents">
/// The updated contents of the notifying list.
/// </param>
///
public delegate void OnUpdateCallback(List<T> updatedContents);
/// <summary>
/// Subscribers to be notified whenever this list is changed.
/// </summary>
public event OnUpdateCallback OnUpdate;
}
}