58 lines
1.3 KiB
C#
58 lines
1.3 KiB
C#
namespace WarhoundConsole
|
|
{
|
|
public sealed class Singleton
|
|
{
|
|
public sealed class InitializeParams
|
|
{
|
|
// FILL SOMETHING
|
|
}
|
|
|
|
public static Singleton I => i ??= new();
|
|
private static Singleton? i = null;
|
|
|
|
private bool isInitialized;
|
|
|
|
public bool ExitRequested { get; private set; }
|
|
|
|
private Singleton()
|
|
{
|
|
this.isInitialized = false;
|
|
this.ExitRequested = false;
|
|
}
|
|
|
|
public bool Initialize(InitializeParams initializeParams)
|
|
{
|
|
try
|
|
{
|
|
if (this.isInitialized)
|
|
{
|
|
throw new InvalidOperationException("이미 초기화된 싱글톤");
|
|
}
|
|
|
|
if (initializeParams == null)
|
|
{
|
|
throw new ArgumentNullException(nameof(initializeParams));
|
|
}
|
|
|
|
this.InitializeInternal(initializeParams);
|
|
}
|
|
finally
|
|
{
|
|
this.isInitialized = true;
|
|
}
|
|
|
|
return true;
|
|
}
|
|
|
|
private void InitializeInternal(InitializeParams initializeParams)
|
|
{
|
|
// DO SOMETHING
|
|
}
|
|
|
|
public void Exit()
|
|
{
|
|
this.ExitRequested = true;
|
|
}
|
|
}
|
|
}
|