Пример #1
0
 private static void CheckInstance()
 {
     //IL_0030: Unknown result type (might be due to invalid IL or missing references)
     //IL_0036: Expected O, but got Unknown
     if (!(Instance != null))
     {
         try
         {
             Instance = Object.FindObjectOfType <UpdateDelegator>();
             if (Instance == null)
             {
                 GameObject val = new GameObject("Update Delegator");
                 val.set_hideFlags(61);
                 try
                 {
                     Object.DontDestroyOnLoad(val);
                 }
                 catch
                 {
                 }
                 val.AddComponent <UpdateDelegator>();
             }
         }
         catch (Exception ex)
         {
             Debug.LogErrorFormat("Caught {0} in UpdateDelegator.CheckInstance: {1}", new object[2]
             {
                 ex.GetType().Name,
                 ex.Message
             });
             throw;
             IL_0085 :;
         }
     }
 }
Пример #2
0
 public static void SendRequest(string endpoint, HTTPMethods method, ApiContainer responseContainer = null, Dictionary <string, object> requestParams = null, bool authenticationRequired = true, bool disableCache = false, float cacheLifetime = 3600f, int retryCount = 2, CredentialsBundle credentials = null)
 {
     if (Logger.DebugLevelIsEnabled(DebugLevel.API))
     {
         Logger.LogFormat(DebugLevel.API, "Requesting {0} {1} {2} disableCache: {3} retryCount: {4}", method, endpoint, (requestParams == null) ? "{{}}" : Json.Encode(requestParams).Replace("{", "{{").Replace("}", "}}"), disableCache.ToString(), retryCount.ToString());
     }
     UpdateDelegator.Dispatch(delegate
     {
         SendRequestInternal(endpoint, method, responseContainer, requestParams, authenticationRequired, disableCache, cacheLifetime, retryCount, credentials);
     });
 }
Пример #3
0
 private void OnEnable()
 {
     if (!(Instance == this))
     {
         if (Instance != null)
         {
             Debug.LogError((object)"Two delegators in existence.");
             Object.Destroy(this);
         }
         else
         {
             spawnedThreadID = Thread.CurrentThread.ManagedThreadId;
             Instance        = this;
         }
     }
 }
Пример #4
0
        public unsafe static T Fetch <T>(string id, Action <ApiContainer> onSuccess = null, Action <ApiContainer> onFailure = null, bool disableCache = false) where T : ApiModel, ApiCacheObject, new()
        {
            id = id?.Trim();
            T val = new T();

            val.id = id;
            T model = (T)val;

            if (!disableCache && ApiCache.Fetch(id, ref *(T *)(&model)))
            {
                if (onSuccess != null)
                {
                    UpdateDelegator.Dispatch(delegate
                    {
                        onSuccess(new ApiModelContainer <T>((T)model));
                    });
                }
                return((T)model);
            }
            model.Fetch(onSuccess, onFailure, null, disableCache);
            return((T)model);
        }