38 lines
1.3 KiB
C#
38 lines
1.3 KiB
C#
namespace Syntriax.Engine.Core.Abstract;
|
|
|
|
/// <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 IInitialize
|
|
{
|
|
/// <summary>
|
|
/// Event triggered when the <see cref="Initialize"/> method is called successfully.
|
|
/// </summary>
|
|
event OnInitializedDelegate? OnInitialized;
|
|
|
|
/// <summary>
|
|
/// Event triggered when the <see cref="Finalize"/> method is called successfully.
|
|
/// </summary>
|
|
event OnFinalizedDelegate? OnFinalized;
|
|
|
|
/// <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();
|
|
|
|
delegate void OnInitializedDelegate(IInitialize sender);
|
|
delegate void OnFinalizedDelegate(IInitialize sender);
|
|
}
|