Пример #1
0
        public async Task <T> ExcuteAsync <T>(ASFRequest <T> request) where  T  : ASFResponse
        {
            string result = "";

            try
            {
                request.Head = _sFNetConfig.UserCode;
                result       = await WebUtility.DoPostAsync(request.Url, request.ToXml(), Utility.GetVerifyCode(request.ToXml(), _sFNetConfig.CheckCode));
            }
            catch (Exception e)
            {
                throw e;
            }
            return(new XmlSFResponseParser <T>().Parse(result));
        }
Пример #2
0
        protected virtual string ToXml(Type tyle, ASFRequest <ASFResponse> request)
        {
            MemoryStream  Stream = new MemoryStream();
            XmlSerializer xml    = new XmlSerializer(tyle);

            try
            {
                //序列化对象
                xml.Serialize(Stream, this);
            }
            catch (InvalidOperationException)
            {
                throw;
            }
            Stream.Position = 0;
            StreamReader sr  = new StreamReader(Stream);
            string       str = sr.ReadToEnd();

            sr.Dispose();
            Stream.Dispose();
            return(str);
        }