You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.3 KiB
48 lines
1.3 KiB
using System; |
|
using System.Collections.Generic; |
|
using System.Diagnostics; |
|
using System.Linq.Expressions; |
|
using System.Text; |
|
|
|
namespace ReZero.SuperAPI |
|
{ |
|
public class ResultService: IResultService |
|
{ |
|
public object GetResult(object data, ResultModel result) |
|
{ |
|
if (IsNoConvert(result)) |
|
{ |
|
return data; |
|
} |
|
else if (result?.ResultType == ResultType.File) |
|
{ |
|
return data; |
|
} |
|
else |
|
{ |
|
return GetResultProvider(data, result!); |
|
} |
|
} |
|
|
|
private static object GetResultProvider(object data, ResultModel model) |
|
{ |
|
IResultService actionInstance = GetActionInstance(model); |
|
var result = actionInstance.GetResult(data, model!); |
|
return result; |
|
} |
|
|
|
|
|
private static IResultService GetActionInstance(ResultModel model) |
|
{ |
|
var actionType = Type.GetType(PubConst.Namespace_ResultService + model?.ResultType); |
|
var actionInstance = (IResultService)Activator.CreateInstance(actionType); |
|
return actionInstance; |
|
} |
|
|
|
private static bool IsNoConvert(ResultModel result) |
|
{ |
|
return result == null || result?.ResultType == null; |
|
} |
|
|
|
} |
|
}
|
|
|