Syntriax 61e2761580 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
2025-05-31 00:32:58 +03:00

35 lines
1.2 KiB
C#

namespace Syntriax.Engine.Core;
/// <summary>
/// Represents an entity that can be initialized and finalized. This information is useful for objects we know that are not in use and can be either recycled or dropped for garbage collection.
/// </summary>
public interface IInitializable
{
/// <summary>
/// Event triggered when the <see cref="Initialize"/> method is called successfully.
/// </summary>
Event<IInitializable> OnInitialized { get; }
/// <summary>
/// Event triggered when the <see cref="IInitializable"/> method is called successfully.
/// </summary>
Event<IInitializable> OnFinalized { get; }
/// <summary>
/// The value indicating whether the entity has been initialized.
/// </summary>
bool IsInitialized { get; }
/// <summary>
/// Initializes the entity.
/// </summary>
/// <returns><see cref="true"/> if initialization is successful, otherwise <see cref="false"/>.</returns>
bool Initialize();
/// <summary>
/// Finalizes the entity so it can either be recycled or garbage collected.
/// </summary>
/// <returns><see cref="true"/> if finalization is successful, otherwise <see cref="false"/>.</returns>
bool Finalize();
}