123456789101112131415161718192021222324252627282930313233343536 |
- using LJLib.Net.SPI.Com;
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Threading.Tasks;
- namespace LJProxy.LJLib.Net.SPI.Server
- {
- public abstract class ExcutorBase
- {
- public abstract LJResponse Excute(ILJRequest request,object state);
- }
- public abstract class ExcutorBase<T1,T2>:ExcutorBase where T1: LJRequest<T2> where T2:LJResponse,new()
- {
- protected abstract void ExcuteInternal(T1 request, object state, T2 rslt);
- public override LJResponse Excute(ILJRequest request, object state)
- {
- T2 rslt = new T2();
- try
- {
- T1 req = request as T1;
- if(req == null)
- {
- rslt.ErrMsg = string.Format("request 不能转换成类型[{0}]",typeof(T1).Name);
- return rslt;
- }
- ExcuteInternal(req, state, rslt);
- }catch(Exception e)
- {
- rslt.ErrMsg = e.Message.ToString();
- }
- return rslt;
- }
- }
- }
|