Пример #1
0
        private Task <string> CreateRequestAsync(IModel model)
        {
            var dic = new Dictionary <string, object>();

            var baseModel = model as BaseModel <TBaseContent, TBaseHead>;

            var props = baseModel.content.GetType().GetProperties();

            foreach (var prop in props)
            {
                var name  = prop.Name;
                var value = prop.GetValue(model);
                dic[name] = value;
            }

            props = baseModel.head.GetType().GetProperties();
            foreach (var prop in props)
            {
                var name  = prop.Name;
                var value = prop.GetValue(model);
                dic[name] = value;
            }

            var postData = SignUtil.SetSign <TBaseContent, TBaseHead>(model, dic, MD5Key);

            Console.WriteLine($"请求报文:{postData}");

            var result = WebRequestUtil.PostJsonAsync(Url, postData);

            Console.WriteLine($"接收报文:{result}");

            return(result);
        }