Пример #1
0
        void FinishResponse(Task task)
        {
            if (task.IsCompleted && !task.IsFaulted)
            {
                ResponseDataType = Options.DataType;
                var ev = new DataFilterEventArgs(Options, ResponseText);

                if (Options.DataType == AjaxDataType.Guess)
                    ResponseDataType = GuessDataType();

                if (Options.Filters.ContainsKey(ResponseDataType))
                    (Options.Filters[ResponseDataType] as AjaxFilterHandler).Invoke(this, ev);
                else
                    DefaultFilter(ev);

                ResponseText = ev.ModifiedData;
                var ro = CreateObject(ResponseDataType);
                var args = new AjaxResponseEventArgs(Options, ResponseText, ro);
                IsResolved = true;

                if (Options.StatusCodeHandlers.ContainsKey(StatusCode))
                    (Options.StatusCodeHandlers[StatusCode] as AjaxResponseHandler).Invoke(this, args);

                if (OnSuccess != null)
                    OnSuccess.Invoke(this, args);
            }
            else
            {
                if (OnError != null)
                    OnError.Invoke(this, new AjaxEventArgs(Options));
            }

            ReadyState = WebX.ReadyState.Loaded;

            if (response != null)
                response.Close();

            if (OnComplete != null)
                OnComplete.Invoke(this, new AjaxEventArgs(Options));
        }
Пример #2
0
 void DefaultFilter(DataFilterEventArgs ev)
 {
     //TODO
 }