88 lines
2.4 KiB
C#
88 lines
2.4 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
using ServerCore; using ServerBase;
|
|
|
|
|
|
namespace ServerBase;
|
|
|
|
//=============================================================================================
|
|
// Result 관련 확장 함수
|
|
//
|
|
// author : kangms
|
|
//
|
|
//=============================================================================================
|
|
|
|
public static class ResultHelper
|
|
{
|
|
public static bool isSuccess(this Result result)
|
|
{
|
|
ArgumentNullReferenceCheckHelper.throwIfNull(result, () => $"result is null !!!");
|
|
|
|
if (true == result.ErrorCode.isSuccess())
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public static bool isFail(this Result result)
|
|
{
|
|
ArgumentNullReferenceCheckHelper.throwIfNull(result, () => $"result is null !!!");
|
|
|
|
if (true == result.ErrorCode.isFail())
|
|
{
|
|
return true;
|
|
}
|
|
|
|
return false;
|
|
}
|
|
|
|
public static void setSuccess(this Result result, string resultString = "")
|
|
{
|
|
ArgumentNullReferenceCheckHelper.throwIfNull(result, () => $"result is null !!!");
|
|
|
|
result.set(ServerErrorCode.Success, resultString);
|
|
}
|
|
|
|
public static void setFail(this Result result, ServerErrorCode errorCode, string resultString = "")
|
|
{
|
|
ArgumentNullReferenceCheckHelper.throwIfNull(result, () => $"result is null !!!");
|
|
|
|
result.set(errorCode, resultString);
|
|
}
|
|
|
|
public static string getResultString(this Result result)
|
|
{
|
|
ArgumentNullReferenceCheckHelper.throwIfNull(result, () => $"result is null !!!");
|
|
|
|
return result.ResultString;
|
|
}
|
|
|
|
public static ServerErrorCode getErrorCode(this Result result)
|
|
{
|
|
ArgumentNullReferenceCheckHelper.throwIfNull(result, () => $"result is null !!!");
|
|
|
|
return result.ErrorCode;
|
|
}
|
|
|
|
public static void set(this Result result, ServerErrorCode errorCode, string resultString)
|
|
{
|
|
ArgumentNullReferenceCheckHelper.throwIfNull(result, () => $"result is null !!!");
|
|
|
|
result.ErrorCode = errorCode;
|
|
result.ResultString = resultString;
|
|
}
|
|
|
|
public static string toBasicString(this Result result)
|
|
{
|
|
ArgumentNullReferenceCheckHelper.throwIfNull(result, () => $"result is null !!!");
|
|
|
|
return $"ErrorInfo: errCode:{result.getErrorCode()}, errDesc:{result.getResultString()}";
|
|
}
|
|
} |