示例#1
0
        /// <summary>
        /// Loader has failed
        /// </summary>
        /// <param name="Exception"></param>
        protected virtual void LoaderFailed(Exception Exception)
        {
            this.State = netLoaderState.Failed;
            this.Data  = null;

            try
            {
                // never ever change order of event invokes!
                OnLoadFailed?.Invoke(this);
                CallbackObserver?.OnLoadFailed(this, Exception);
            }
            catch (Exception ex)
            {
                // this is only the exception handling for the event invoke not for the loader itself!
                Debug.WriteLine(ex);
                // ToDo: logging interface
            }
        }
示例#2
0
        public virtual async Task Load()
        {
            if (Identifier != null)
            {
                Response = await HttpService.GetOne <T>(Identifier, new EmptyValidator());

                if (Response.Succeed && Response.Response.Status.Succeeded())
                {
                    Record = Response.Response.Data;
                    OnLoadSucceeded?.Invoke(Response);
                }
                else if (Response.HasException)
                {
                    OnLoadException?.Invoke(Response);
                }
                else
                {
                    OnLoadFailed?.Invoke(Response);
                }
            }
            OnLoad?.Invoke(Response);
        }