Fixed perf issues
This commit is contained in:
@@ -0,0 +1,9 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record Activation
|
||||
{
|
||||
public static ActivationEventArgs<TSender, TValue> As<TSender, TValue>(TValue value) => new(value);
|
||||
|
||||
public static ActivationEventArgs<TSender> As<TSender>() =>
|
||||
new();
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record ActivationBuilder(IActivation Value, object? Key = null);
|
||||
@@ -0,0 +1,7 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record ActivationEventArgs<TSynchronize, TValue>(TValue? Value = default) :
|
||||
IActivation;
|
||||
|
||||
public record ActivationEventArgs<TSynchronize>() :
|
||||
IActivation;
|
||||
@@ -1,3 +1,3 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public interface ISynchronize;
|
||||
public interface IActivation;
|
||||
@@ -74,6 +74,11 @@ public partial class Observable(IServiceProvider provider,
|
||||
Disposer.Dispose(this);
|
||||
}
|
||||
|
||||
public virtual void OnInitialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void Initialize()
|
||||
{
|
||||
if (IsInitialized)
|
||||
@@ -83,6 +88,7 @@ public partial class Observable(IServiceProvider provider,
|
||||
|
||||
IsInitialized = true;
|
||||
Subscriber.Subscribe(this);
|
||||
OnInitialize();
|
||||
}
|
||||
|
||||
public void Revert()
|
||||
|
||||
@@ -266,7 +266,7 @@ public partial class ObservableCollection<TItem> :
|
||||
Disposer.Dispose(this);
|
||||
}
|
||||
|
||||
public void Fetch(Func<SynchronizeExpression> aggregateDelegate,
|
||||
public void Activate(Func<ActivationBuilder> aggregateDelegate,
|
||||
bool reset = false)
|
||||
{
|
||||
if (reset)
|
||||
@@ -274,8 +274,8 @@ public partial class ObservableCollection<TItem> :
|
||||
Clear();
|
||||
}
|
||||
|
||||
SynchronizeExpression expression = aggregateDelegate.Invoke();
|
||||
Publisher.PublishUI(expression.Value, expression.Key);
|
||||
ActivationBuilder expression = aggregateDelegate.Invoke();
|
||||
Publisher.Publish(expression.Value, expression.Key);
|
||||
}
|
||||
|
||||
public IEnumerator<TItem> GetEnumerator() =>
|
||||
@@ -415,6 +415,11 @@ public partial class ObservableCollection<TItem> :
|
||||
IsCompatibleObject(value) ?
|
||||
IndexOf((TItem)value!) : -1;
|
||||
|
||||
public virtual void OnInitialize()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public virtual void Initialize()
|
||||
{
|
||||
if (IsInitialized)
|
||||
@@ -423,9 +428,10 @@ public partial class ObservableCollection<TItem> :
|
||||
}
|
||||
|
||||
IsInitialized = true;
|
||||
|
||||
Subscriber.Subscribe(this);
|
||||
Synchronize();
|
||||
OnInitialize();
|
||||
|
||||
Activate();
|
||||
}
|
||||
|
||||
public TItem Insert<T>(int index = 0,
|
||||
@@ -570,15 +576,15 @@ public partial class ObservableCollection<TItem> :
|
||||
}
|
||||
}
|
||||
|
||||
public void Synchronize(bool reset = false)
|
||||
public void Activate(bool reset = false)
|
||||
{
|
||||
if (reset)
|
||||
{
|
||||
Clear();
|
||||
}
|
||||
|
||||
SynchronizeExpression expression = BuildAggregateExpression();
|
||||
Publisher.PublishUI(expression.Value, expression.Key);
|
||||
ActivationBuilder builder = ActivationBuilder();
|
||||
Publisher.PublishUI(builder.Value, builder.Key);
|
||||
}
|
||||
|
||||
public void Track<T>(string propertyName, Func<T> getter, Action<T> setter)
|
||||
@@ -590,8 +596,8 @@ public partial class ObservableCollection<TItem> :
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual SynchronizeExpression BuildAggregateExpression() =>
|
||||
new(new SynchronizeEventArgs<TItem>());
|
||||
protected virtual ActivationBuilder ActivationBuilder() =>
|
||||
new(new ActivationEventArgs<TItem>());
|
||||
|
||||
protected virtual void ClearItems() =>
|
||||
collection.Clear();
|
||||
|
||||
@@ -1,9 +0,0 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record Synchronize
|
||||
{
|
||||
public static SynchronizeEventArgs<TValue, TOptions> As<TValue, TOptions>(TOptions options) => new(options);
|
||||
|
||||
public static SynchronizeEventArgs<TValue> As<TValue>() =>
|
||||
new();
|
||||
}
|
||||
@@ -1,7 +0,0 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record SynchronizeEventArgs<TSynchronize, TValue>(TValue? Value = default) :
|
||||
ISynchronize;
|
||||
|
||||
public record SynchronizeEventArgs<TSynchronize>() :
|
||||
ISynchronize;
|
||||
@@ -1,3 +0,0 @@
|
||||
namespace Toolkit.Foundation;
|
||||
|
||||
public record SynchronizeExpression(ISynchronize Value, object? Key = null);
|
||||
Reference in New Issue
Block a user