perf!: events refactored throughout all the project to use Event<> class
All delegate events are refactored to use the Event<TSender> and Event<TSender, TArgument> for performance issues regarding delegate events creating garbage, also this gives us better control on event invocation since C# Delegates did also create unnecessary garbage during Delegate.DynamicInvoke
This commit is contained in:
@@ -18,7 +18,7 @@ public class Shape2D(List<Vector2D> vertices) : IEnumerable<Vector2D>
|
||||
public static Shape2D Pentagon => CreateNgon(5, Vector2D.Up);
|
||||
public static Shape2D Hexagon => CreateNgon(6, Vector2D.Right);
|
||||
|
||||
public event ShapeUpdatedEventHandler? OnShapeUpdated = null;
|
||||
public Event<Shape2D> OnShapeUpdated { get; } = new();
|
||||
|
||||
private List<Vector2D> _vertices = vertices;
|
||||
|
||||
@@ -256,8 +256,6 @@ public class Shape2D(List<Vector2D> vertices) : IEnumerable<Vector2D>
|
||||
|
||||
/// <inheritdoc/>
|
||||
IEnumerator IEnumerable.GetEnumerator() => Vertices.GetEnumerator();
|
||||
|
||||
public delegate void ShapeUpdatedEventHandler(Shape2D shape2D);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
Reference in New Issue
Block a user