both for now

This commit is contained in:
mischa 2024-10-14 12:42:10 +02:00 committed by mischa
parent b57984ab59
commit 2bf70f3bc9

View File

@ -33,9 +33,7 @@ public enum Operation : byte
/// <para>For OP_SET and OP_REMOVE, T is the OLD value of the entry.</para> /// <para>For OP_SET and OP_REMOVE, T is the OLD value of the entry.</para>
/// <para>For OP_CLEAR, T is default.</para> /// <para>For OP_CLEAR, T is default.</para>
/// </summary> /// </summary>
// DEPRECATED 2024-10-14
// TODO deprecate in favor of explicit Callback, later rename Callback to OnChange for consistency with other SyncCollections. // TODO deprecate in favor of explicit Callback, later rename Callback to OnChange for consistency with other SyncCollections.
[Obsolete("SyncList.OnChange(op, index, item) is obsolete. Use SyncList.Callback(op, index, oldItem, newItem) instead.")]
public Action<Operation, int, T> OnChange; public Action<Operation, int, T> OnChange;
/// <summary> /// <summary>
@ -121,37 +119,27 @@ void AddOperation(Operation op, int itemIndex, T oldItem, T newItem, bool checkA
{ {
case Operation.OP_ADD: case Operation.OP_ADD:
OnAdd?.Invoke(itemIndex); OnAdd?.Invoke(itemIndex);
#pragma warning disable CS0618
OnChange?.Invoke(op, itemIndex, newItem); OnChange?.Invoke(op, itemIndex, newItem);
#pragma warning restore CS0618
Callback?.Invoke(op, itemIndex, oldItem, newItem); Callback?.Invoke(op, itemIndex, oldItem, newItem);
break; break;
case Operation.OP_INSERT: case Operation.OP_INSERT:
OnInsert?.Invoke(itemIndex); OnInsert?.Invoke(itemIndex);
#pragma warning disable CS0618
OnChange?.Invoke(op, itemIndex, newItem); OnChange?.Invoke(op, itemIndex, newItem);
#pragma warning restore CS0618
Callback?.Invoke(op, itemIndex, oldItem, newItem); Callback?.Invoke(op, itemIndex, oldItem, newItem);
break; break;
case Operation.OP_SET: case Operation.OP_SET:
OnSet?.Invoke(itemIndex, oldItem); OnSet?.Invoke(itemIndex, oldItem);
#pragma warning disable CS0618
OnChange?.Invoke(op, itemIndex, oldItem); OnChange?.Invoke(op, itemIndex, oldItem);
#pragma warning restore CS0618
Callback?.Invoke(op, itemIndex, oldItem, newItem); Callback?.Invoke(op, itemIndex, oldItem, newItem);
break; break;
case Operation.OP_REMOVEAT: case Operation.OP_REMOVEAT:
OnRemove?.Invoke(itemIndex, oldItem); OnRemove?.Invoke(itemIndex, oldItem);
#pragma warning disable CS0618
OnChange?.Invoke(op, itemIndex, oldItem); OnChange?.Invoke(op, itemIndex, oldItem);
#pragma warning restore CS0618
Callback?.Invoke(op, itemIndex, oldItem, newItem); Callback?.Invoke(op, itemIndex, oldItem, newItem);
break; break;
case Operation.OP_CLEAR: case Operation.OP_CLEAR:
OnClear?.Invoke(); OnClear?.Invoke();
#pragma warning disable CS0618
OnChange?.Invoke(op, itemIndex, default); OnChange?.Invoke(op, itemIndex, default);
#pragma warning restore CS0618
Callback?.Invoke(op, itemIndex, default, default); Callback?.Invoke(op, itemIndex, default, default);
break; break;
} }