示例#1
0
 public VoucherListRequest(CallerRequest callerRequest)
 {
     AppKey      = callerRequest.AppKey;
     FromAccount = callerRequest.FromAccount;
     ToAccount   = callerRequest.ToAccount;
     Token       = callerRequest.Token;
 }
示例#2
0
文件: Api.cs 项目: microfeel/Yonyou
        /// <summary>
        /// 获取标准的请求类型实例
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <returns></returns>
        protected async Task <T> GetRequestTypeAsync <T>() where T : ApiRequest, new()
        {
            T t = new T();

            switch (t.GetType().Name)
            {
            case nameof(TokenRequest):
                t = new TokenRequest {
                    AppKey = _appKey, AppSecret = _appSecret, FromAccount = _fromAccount
                } as T;
                break;

            case nameof(CallerRequest):
                t = new CallerRequest
                {
                    AppKey      = _appKey,
                    FromAccount = _fromAccount,
                    ToAccount   = _toAccount,
                    Token       = await TokenManager.GetTokenAsync(BaseUrl, _appKey, _appSecret, _fromAccount, _toAccount),
                } as T;
                break;

            case nameof(DsRequest):
                t = new DsRequest
                {
                    AppKey      = _appKey,
                    FromAccount = _fromAccount,
                    ToAccount   = _toAccount,
                    Token       = await TokenManager.GetTokenAsync(BaseUrl, _appKey, _appSecret, _fromAccount, _toAccount),
                } as T;
                break;

            case nameof(BaseRequest):
            default:
                t = new BaseRequest
                {
                    AppKey      = _appKey,
                    FromAccount = _fromAccount,
                    Token       = await TokenManager.GetTokenAsync(BaseUrl, _appKey, _appSecret, _fromAccount, _toAccount),
                } as T;
                break;
            }
            return(t);
        }