mirror of
https://github.com/KevinWG/OSS.Common.git
synced 2026-10-28 22:04:09 +08:00
@@ -23,7 +23,7 @@ namespace OSS.Common.ComModels.Enums
|
||||
/// 成功
|
||||
/// </summary>
|
||||
[OSDescript("正常")] None = 0,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 无法连接
|
||||
/// </summary>
|
||||
@@ -33,16 +33,26 @@ namespace OSS.Common.ComModels.Enums
|
||||
/// 超时
|
||||
/// </summary>
|
||||
[OSDescript("超时")] TimeOut = 200,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// 任务失败
|
||||
/// </summary>
|
||||
[OSDescript("任务失败")] TaskFailed = 300,
|
||||
|
||||
/// <summary>
|
||||
/// 等待重试
|
||||
/// </summary>
|
||||
[OSDescript("等待重试")] WaitRetry = 400,
|
||||
|
||||
/// <summary>
|
||||
/// 内部错误(服务器错误)
|
||||
/// </summary>
|
||||
[OSDescript("内部错误")] InnerError = 500,
|
||||
[OSDescript("系统错误")] InnerError = 500,
|
||||
|
||||
/// <summary>
|
||||
/// 等待重试
|
||||
/// </summary>
|
||||
[OSDescript("等待响应")] WaitingResponse = 600,
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
@@ -17,11 +17,28 @@ namespace OSS.Common.ComUtils
|
||||
get
|
||||
{
|
||||
if (instanceCreater == null)
|
||||
throw new Exception(string.Concat( " 并没有设置", typeof(T).Name, "对应的映射类型! "));
|
||||
throw new Exception(string.Concat(" 并没有设置", typeof(T).Name, "对应的映射类型! "));
|
||||
return instanceCreater();
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 获取类型实例
|
||||
/// </summary>
|
||||
/// <param name="t"></param>
|
||||
/// <returns></returns>
|
||||
public static bool TryGet(out T t)
|
||||
{
|
||||
if (instanceCreater == null)
|
||||
{
|
||||
t = default(T);
|
||||
return false;
|
||||
}
|
||||
|
||||
t = instanceCreater();
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
private static Func<T> instanceCreater;
|
||||
private static T instance;
|
||||
@@ -37,7 +54,7 @@ namespace OSS.Common.ComUtils
|
||||
if (instanceCreater == null)
|
||||
instanceCreater = () =>
|
||||
{
|
||||
if(isSingle) return new TInstance();
|
||||
if (isSingle) return new TInstance();
|
||||
|
||||
if (instance != null) return instance;
|
||||
return instance = new TInstance();
|
||||
|
||||
Reference in New Issue
Block a user