public void SaveAsyncDelayed()
 {
     if (saver == null)
     {
         DebugFormat.LogError(this, "Saver is not initialized!");
     }
     saver.data = PrepeareDataBeforeSave(Data);
     saver.SaveAsyncDelayed();
     onSaveStarted.OnNext(Data);
 }
 public T Load()
 {
     if (saver == null)
     {
         DebugFormat.LogError(this, "Saver is not initialized!");
     }
     Data = PrepareData(saver.Load());
     NotifyLoadingDataListeners(loadingDataListeners, Data);
     return(Data);
 }
예제 #3
0
    public DebugRequestEvents(CompositeDisposable compositeDisposable, Request <T> request, int id) : base()
    {
#if UNITY_EDITOR
        OnSuccess.Subscribe(x => DebugFormat.Log <Request <T> >($"[{request.RESTMethod}] {id} - OnSuccess\n\n{JsonConvert.SerializeObject(x, Formatting.Indented)}\n", deep: DEEP)).AddTo(compositeDisposable);
        OnSuccessRaw.Subscribe(x => DebugFormat.Log <Request <T> >($"[{request.RESTMethod}] {id} - OnSuccessRaw\n\n{Request<T>.JsonPrettify(x)}\n", deep: DEEP)).AddTo(compositeDisposable);
#endif
        OnSerializationError.Subscribe(x => DebugFormat.LogError <Request <T> >($"[{request.RESTMethod}] {id} - OnSerializationError: {x}", deep: DEEP)).AddTo(compositeDisposable);
        OnHttpError.Subscribe(x => DebugFormat.LogError <Request <T> >($"[{request.RESTMethod}] {id} - OnHttpError\n\n {JsonConvert.SerializeObject(x, Formatting.Indented)}\n", deep: DEEP)).AddTo(compositeDisposable);
        OnHttpErrorRaw.Subscribe(x => DebugFormat.LogError <Request <T> >($"[{request.RESTMethod}] {id} - OnHttpErrorRaw\n\n{x}\n", deep: DEEP)).AddTo(compositeDisposable);
        OnNetworkError.Subscribe(x => DebugFormat.LogError <Request <T> >($"[{request.RESTMethod}] {id} - OnNetworkError\n\n {JsonConvert.SerializeObject(x, Formatting.Indented)}\n", deep: DEEP)).AddTo(compositeDisposable);
    }
 public Task LoadAsync()
 {
     if (saver == null)
     {
         DebugFormat.LogError(this, "Saver is not initialized!");
     }
     return(saver.LoadAsync(task =>
     {
         Data = PrepareData(saver.data);
         NotifyLoadingDataListeners(loadingDataListeners, Data);
     }));
 }
예제 #5
0
    protected virtual K                                                               FromJSON <K>                                             (UnityWebRequest unityRequest)
    {
        string json = null;

        try
        {
            json = GetJSON(unityRequest);
            var result = JsonConvert.DeserializeObject <K>(json, jsonSerializerSettings);
            return(result);
        }
        catch (Exception e)
        {
            Events.SendSerializationError(e.Message);
            DebugFormat.LogException <Request <T> >(e);

            try                                     { DebugFormat.LogError(this, $"JSON ({typeof(K).Name}):\n\n{JsonPrettify(json)}\n"); }
            catch (Exception e2) { DebugFormat.LogError(this, $"JSON ({typeof(K).Name}):\n\n{json}\n"); }
        }
        return(default(K));
    }