Example #1
0
        public async Task <List <Image> > GetImagesHttp()
        {
            ImageList.IO.HttpIORequest request = new ImageList.IO.HttpIORequest();
            request.URI                 = "http://md5.jsontest.com/";
            request.Verb                = ImageList.IO.HttpVerb.GET;
            request.ContentType         = ImageList.IO.DataType.JSON;
            request.Authentication      = ImageList.IO.AuthType.NONE;
            request.QueryString         = new Dictionary <string, string>();
            request.QueryString["text"] = "example_text";

            TransactionCookie httpTransaction = new TransactionCookie(1, this);

            httpTransaction.Request = request;
            HttpIO <HttpIOHandler> httpIO = new HttpIO <HttpIOHandler>(httpTransaction);
            //httpIO.OnHttpAppException += ((msg) =>
            //{
            //    //Log(msg);
            //});
            //httpIO.OnHttpFatalException += ((msg) =>
            //{
            //    //Log(msg);
            //});
            List <Image> imgLst = await httpIO.ExecAsync <List <Image> >(request).ConfigureAwait(false);

            return(imgLst);

            // JSON parsing without serialization...
            if (imgLst != null)
            {
                string         md5      = "";
                bool           bReadNxt = false;
                JsonTextReader reader   = new JsonTextReader(new StringReader(imgLst.ToString()));
                while (reader.Read())
                {
                    /*
                     * TokenType "PropertyName" means its a JSON Key
                     * Corresponding Value represents the key Name
                     * TokenType for a JSON value is the data type like String, Boolean, Integer...
                     * Corresponding Value is the value of the JSON Value
                     */
                    if (reader.Value != null)
                    {
                        //Log(string.Format("Token: {0}, Value: {1}", reader.TokenType, reader.Value));
                        if (bReadNxt)
                        {
                            md5      = reader.Value.ToString();
                            bReadNxt = false;
                            //Log(string.Format("VALUE: {0}", md5));
                        }
                        if (reader.TokenType.ToString() == "PropertyName" &&
                            reader.Value.ToString() == "md5")
                        {
                            bReadNxt = true;
                        }
                    }
                    else
                    {
                        //Log(string.Format("Token: {0}", reader.TokenType));
                    }
                }
            }
        }
Example #2
0
        public async Task<List<Image>> GetImagesHttp()
        {
            ImageList.IO.HttpIORequest request = new ImageList.IO.HttpIORequest();
            request.URI = "http://md5.jsontest.com/";
            request.Verb = ImageList.IO.HttpVerb.GET;
            request.ContentType = ImageList.IO.DataType.JSON;
            request.Authentication = ImageList.IO.AuthType.NONE;
            request.QueryString = new Dictionary<string, string>();
            request.QueryString["text"] = "example_text";

            TransactionCookie httpTransaction = new TransactionCookie(1, this);
            httpTransaction.Request = request;
            HttpIO<HttpIOHandler> httpIO = new HttpIO<HttpIOHandler>(httpTransaction);
            //httpIO.OnHttpAppException += ((msg) =>
            //{
            //    //Log(msg);
            //});
            //httpIO.OnHttpFatalException += ((msg) =>
            //{
            //    //Log(msg);
            //});
            List<Image> imgLst = await httpIO.ExecAsync<List<Image>>(request).ConfigureAwait(false);
            return imgLst;
            // JSON parsing without serialization...
            if (imgLst != null)
            {
                string md5 = "";
                bool bReadNxt = false;
                JsonTextReader reader = new JsonTextReader(new StringReader(imgLst.ToString()));
                while (reader.Read())
                {
                    /*
                     * TokenType "PropertyName" means its a JSON Key
                     * Corresponding Value represents the key Name
                     * TokenType for a JSON value is the data type like String, Boolean, Integer...
                     * Corresponding Value is the value of the JSON Value
                     */
                    if (reader.Value != null)
                    {
                        //Log(string.Format("Token: {0}, Value: {1}", reader.TokenType, reader.Value));
                        if (bReadNxt)
                        {
                            md5 = reader.Value.ToString();
                            bReadNxt = false;
                            //Log(string.Format("VALUE: {0}", md5));
                        }
                        if (reader.TokenType.ToString() == "PropertyName"
                            && reader.Value.ToString() == "md5")
                            bReadNxt = true;
                    }
                    else
                    {
                        //Log(string.Format("Token: {0}", reader.TokenType));
                    }
                }
            }
        }