Exemplo n.º 1
0
        private void Success <TModel>(string response, WrappedAsyncCompletedEventArgs e)
        {
            var           value     = JsonConvert.DeserializeObject <TModel>(response, new StringEnumConverter());
            HttpException exception = value != null ? null : new HttpException((int)HttpStatusCode.NoContent,
                                                                               string.Format("An error occurred while deserializing the response: {0}", response));
            HydrateCompletedEventArgs args = new HydrateCompletedEventArgs(typeof(TModel), value,
                                                                           exception, false, e.UserState, e.OriginalUrl, response);

            OnHydrateCompleted <TModel>(args);
        }
Exemplo n.º 2
0
        /// <summary>
        /// Raises the <see cref="E:Geocrest.Model.RestHelper.HydrateCompleted"/> event.
        /// </summary>
        /// <param name="e">The event arguments containing the hydrated object or an exception if the operation failed.</param>
        protected void OnHydrateCompleted <T>(HydrateCompletedEventArgs e)
        {
            this.WebHelper.DownloadStringCompleted -= WebHelper_DownloadStringCompleted <T>;
            this.WebHelper.UploadStringCompleted   -= WebHelper_UploadStringCompleted <T>;
            this.WebHelper.UploadValuesCompleted   -= WebHelper_UploadValuesCompleted <T>;
            EventHandler <HydrateCompletedEventArgs> handler = HydrateCompleted;

            if (handler != null)
            {
                handler(this, e);
            }
        }