Syntriax.Engine/Engine.Core/Abstract/IInitialize.cs

38 lines
1.3 KiB
C#
Raw Normal View History

2023-11-23 22:07:49 +03:00
namespace Syntriax.Engine.Core.Abstract;
2024-02-01 12:14:53 +03:00
/// <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
2023-11-23 22:07:49 +03:00
{
2024-02-01 12:14:53 +03:00
/// <summary>
/// Event triggered when the <see cref="Initialize"/> method is called successfully.
/// </summary>
event OnInitializedEventHandler? OnInitialized;
2024-02-01 12:14:53 +03:00
/// <summary>
/// Event triggered when the <see cref="Finalize"/> method is called successfully.
/// </summary>
event OnFinalizedEventHandler? OnFinalized;
2024-02-01 12:14:53 +03:00
/// <summary>
/// The value indicating whether the entity has been initialized.
/// </summary>
bool IsInitialized { get; }
2023-11-23 22:07:49 +03:00
2024-02-01 12:14:53 +03:00
/// <summary>
/// Initializes the entity.
/// </summary>
/// <returns><see cref="true"/> if initialization is successful, otherwise <see cref="false"/>.</returns>
2023-11-23 22:07:49 +03:00
bool Initialize();
2024-02-01 12:14:53 +03:00
/// <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>
2023-11-23 22:07:49 +03:00
bool Finalize();
2024-07-15 01:13:39 +03:00
delegate void OnInitializedEventHandler(IInitialize sender);
delegate void OnFinalizedEventHandler(IInitialize sender);
2023-11-23 22:07:49 +03:00
}