src/Library/NetPro.Startup/EngineContext.cs
(完整代码) 1KBusing System.Runtime.CompilerServices;
namespace System.NetPro
{
/// <summary>
/// NetPro Engine 单例实现
/// </summary>
public class EngineContext
{
#region Methods
private EngineContext()
{
}
/// <summary>
/// 返回NetProEngine 单例对象
/// </summary>
[MethodImpl(MethodImplOptions.Synchronized)]
public static IEngine Create()
{
//create NetProEngine as engine
return Singleton<IEngine>.Instance ?? (Singleton<IEngine>.Instance = new NetProEngine());
}
/// <summary>
/// Sets the static engine instance to the supplied engine. Use this method to supply your own engine implementation.
/// </summary>
/// <param name="engine">The engine to use.</param>
/// <remarks>Only use this method if you know what you're doing.</remarks>
public static void Replace(IEngine engine)
{
Singleton<IEngine>.Instance = engine;
}
#endregion
#region Properties
/// <summary>
///当前IEngine对象
/// </summary>
public static IEngine Current
{
get
{
if (Singleton<IEngine>.Instance == null)
{
Create();
}
return Singleton<IEngine>.Instance;
}
}
#endregion
}
}
24 小时内免费解锁 3 个项目,之后 1 算力/个。 规则说明
AI 解读 AI
登录后可用,每次 10 算力,解读结果公开显示在下面。
还没有人解读过这个文件。