예제 #1
0
        public async Task <TResult> GetAsync <TInput, TResult>(TInput input, bool propertyNameLower = true)
            where TInput : IApiInputDto
            where TResult : class, IApiResultDto
        {
            var attribute = GetApiUrl <TInput>();
            var url       = attribute.GetUrl();

            input.CounterSign();
            var properties = input.GetType().GetProperties();
            //if (properties.Length <= 0) throw new UserFriendlyException("input is null");

            var parames = "";

            for (int i = 0; i < properties.Length; i++)
            {
                var curproperty = properties[i];
                parames += $"{(i > 0 ? "&" : "")}{(propertyNameLower ? curproperty.Name.ToLower() : curproperty.Name)}={curproperty.GetValue(input, null)}";
            }
            //ApiLogHelper.Logger.Debug($"GET URL:{url}\r\n参数:{parames}");
            var result = await apiContext.GetAsync <TResult>($"{url}?{parames}");

            //if (!result.Success) throw new UserFriendlyException(result.Error.Message);
            return(result);
        }