Got adding working again

This commit is contained in:
TheXamlGuy
2024-05-19 22:21:18 +01:00
parent 72a37c7275
commit 1190303044
5 changed files with 36 additions and 26 deletions
-10
View File
@@ -1,10 +0,0 @@
namespace Toolkit.Foundation;
public record Aggerate<TValue, TOptions>(TOptions? Options = null) :
IAggerate
where TOptions : class
{
public object? Key { get; init; }
public AggerateMode Mode { get; init; }
}
+7
View File
@@ -0,0 +1,7 @@
namespace Toolkit.Foundation;
public class AggerateAttribute(object key,
AggerateMode mode = AggerateMode.Reset) : NotificationAttribute(key)
{
public AggerateMode Mode => mode;
}
+23 -4
View File
@@ -1,12 +1,31 @@
namespace Toolkit.Foundation; namespace Toolkit.Foundation;
public record Aggerate
{
public static AggerateEventArgs<TValue, TOptions> With<TValue, TOptions>(TOptions options) where TOptions : class
{
return new AggerateEventArgs<TValue, TOptions>(options);
}
public static AggerateEventArgs<TValue> With<TValue>()
{
return new AggerateEventArgs<TValue>();
}
}
public record AggerateEventArgs<TValue, TOptions>(TOptions? Options = null) :
IAggerate
where TOptions : class
{
public object? Key { get; init; }
public AggerateMode Mode { get; init; }
}
public record AggerateEventArgs<TValue> : public record AggerateEventArgs<TValue> :
IAggerate IAggerate
{ {
public object? Key { get; init; } public object? Key { get; init; }
public static Aggerate<TValue, TOptions> With<TOptions>(TOptions options) where TOptions : class public AggerateMode Mode { get; init; }
{
return new Aggerate<TValue, TOptions>(options);
}
} }
@@ -5,9 +5,3 @@ public class NotificationAttribute(object key) : Attribute
{ {
public object Key => key; public object Key => key;
} }
public class EnumerateAttribute(object key,
AggerateMode mode = AggerateMode.Reset) : NotificationAttribute(key)
{
public AggerateMode Mode => mode;
}
+5 -5
View File
@@ -250,9 +250,9 @@ public partial class ObservableCollection<TItem> :
Disposer.Dispose(this); Disposer.Dispose(this);
} }
public void Aggerate() public void BeginAggregation()
{ {
if (this.GetAttribute<EnumerateAttribute>() is EnumerateAttribute attribute) if (this.GetAttribute<AggerateAttribute>() is AggerateAttribute attribute)
{ {
if (attribute.Mode == AggerateMode.Reset) if (attribute.Mode == AggerateMode.Reset)
{ {
@@ -260,7 +260,7 @@ public partial class ObservableCollection<TItem> :
} }
object? key = this.GetPropertyValue(() => attribute.Key) is { } value ? value : attribute.Key; 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<TItem> :
} }
Initialized = true; Initialized = true;
Aggerate(); BeginAggregation();
return Task.CompletedTask; return Task.CompletedTask;
} }
@@ -442,7 +442,7 @@ public partial class ObservableCollection<TItem> :
collection.Insert(index, item); collection.Insert(index, item);
} }
protected virtual IAggerate OnAggerate(object? key) => protected virtual IAggerate OnPrepareAggregation(object? key) =>
new AggerateEventArgs<TItem>() with { Key = key }; new AggerateEventArgs<TItem>() with { Key = key };
protected virtual void RemoveItem(int index) => protected virtual void RemoveItem(int index) =>