Ejemplo n.º 1
0
        /// Helper method to hydrate an object using the string response from the specified URL resource
        /// and without requiring a <see cref="T:Geocrest.Model.RestHelper"/>.
        /// <typeparam name="T">The type of object to hydrate.</typeparam>
        /// <param name="url">The web service URL.</param>
        /// <param name="nvc">The data to upload as name/value pairs.</param>
        /// <param name="method">The method to use for uploading. Defaults to <c>POST</c>.</param>
        /// <returns></returns>
        public static T HydrateObject <T>(string url, NameValueCollection nvc, string method = "POST")
        {
            RestHelper helper     = new RestHelper();
            var        response   = helper.WebHelper.UploadValues(url, method, nvc);
            var        respString = System.Text.Encoding.Default.GetString(response);

            return(helper.HydrateFromJson <T>(respString));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Helper method to hydrate an object from a json string representation
        /// and without requiring a <see cref="T:Geocrest.Model.RestHelper"/>.
        /// </summary>
        /// <typeparam name="T">The type of object to hydrate.</typeparam>
        /// <param name="json">The string representation of json used to deserialize.</param>
        /// <returns>The hydrated object.</returns>
        public static T HydrateObjectFromJson <T>(string json)
        {
            RestHelper helper = new RestHelper();

            return(helper.HydrateFromJson <T>(json));
        }