diff --git a/Toolkit.Foundation/Aggerate.cs b/Toolkit.Foundation/Aggerate.cs deleted file mode 100644 index b88032f..0000000 --- a/Toolkit.Foundation/Aggerate.cs +++ /dev/null @@ -1,10 +0,0 @@ -namespace Toolkit.Foundation; - -public record Aggerate(TOptions? Options = null) : - IAggerate - where TOptions : class -{ - public object? Key { get; init; } - - public AggerateMode Mode { get; init; } -} \ No newline at end of file diff --git a/Toolkit.Foundation/AggerateAttribute.cs b/Toolkit.Foundation/AggerateAttribute.cs new file mode 100644 index 0000000..24b5b14 --- /dev/null +++ b/Toolkit.Foundation/AggerateAttribute.cs @@ -0,0 +1,7 @@ +namespace Toolkit.Foundation; + +public class AggerateAttribute(object key, + AggerateMode mode = AggerateMode.Reset) : NotificationAttribute(key) +{ + public AggerateMode Mode => mode; +} \ No newline at end of file diff --git a/Toolkit.Foundation/AggerateEventArgs.cs b/Toolkit.Foundation/AggerateEventArgs.cs index 1693463..650e0b1 100644 --- a/Toolkit.Foundation/AggerateEventArgs.cs +++ b/Toolkit.Foundation/AggerateEventArgs.cs @@ -1,12 +1,31 @@ namespace Toolkit.Foundation; -public record AggerateEventArgs : +public record Aggerate +{ + public static AggerateEventArgs With(TOptions options) where TOptions : class + { + return new AggerateEventArgs(options); + } + + public static AggerateEventArgs With() + { + return new AggerateEventArgs(); + } +} + +public record AggerateEventArgs(TOptions? Options = null) : + IAggerate + where TOptions : class +{ + public object? Key { get; init; } + + public AggerateMode Mode { get; init; } +} + +public record AggerateEventArgs : IAggerate { public object? Key { get; init; } - public static Aggerate With(TOptions options) where TOptions : class - { - return new Aggerate(options); - } + public AggerateMode Mode { get; init; } } \ No newline at end of file diff --git a/Toolkit.Foundation/NotificationAttribute.cs b/Toolkit.Foundation/NotificationAttribute.cs index 50178f7..fa731b3 100644 --- a/Toolkit.Foundation/NotificationAttribute.cs +++ b/Toolkit.Foundation/NotificationAttribute.cs @@ -5,9 +5,3 @@ public class NotificationAttribute(object key) : Attribute { public object Key => key; } - -public class EnumerateAttribute(object key, - AggerateMode mode = AggerateMode.Reset) : NotificationAttribute(key) -{ - public AggerateMode Mode => mode; -} \ No newline at end of file diff --git a/Toolkit.Foundation/ObservableCollection.cs b/Toolkit.Foundation/ObservableCollection.cs index 9eb094a..6beebc8 100644 --- a/Toolkit.Foundation/ObservableCollection.cs +++ b/Toolkit.Foundation/ObservableCollection.cs @@ -250,9 +250,9 @@ public partial class ObservableCollection : Disposer.Dispose(this); } - public void Aggerate() + public void BeginAggregation() { - if (this.GetAttribute() is EnumerateAttribute attribute) + if (this.GetAttribute() is AggerateAttribute attribute) { if (attribute.Mode == AggerateMode.Reset) { @@ -260,7 +260,7 @@ public partial class ObservableCollection : } object? key = this.GetPropertyValue(() => attribute.Key) is { } value ? value : attribute.Key; - Publisher.PublishUI(OnAggerate(key)); + Publisher.PublishUI(OnPrepareAggregation(key)); } } @@ -338,7 +338,7 @@ public partial class ObservableCollection : } Initialized = true; - Aggerate(); + BeginAggregation(); return Task.CompletedTask; } @@ -442,7 +442,7 @@ public partial class ObservableCollection : collection.Insert(index, item); } - protected virtual IAggerate OnAggerate(object? key) => + protected virtual IAggerate OnPrepareAggregation(object? key) => new AggerateEventArgs() with { Key = key }; protected virtual void RemoveItem(int index) =>