Esempio n. 1
0
    private void ProcessReceivedLandsData(Promise <List <Land> > landPromise, string jsonValue, string lowerCaseAddress, bool cache)
    {
        bool        hasException = false;
        List <Land> lands        = null;

        try
        {
            LandQueryResultWrapped result = JsonUtility.FromJson <LandQueryResultWrapped>(jsonValue);
            lands = LandHelper.ConvertQueryResult(result.data, lowerCaseAddress);

            if (cache)
            {
                landQueryCache.Add(lowerCaseAddress, lands, DEFAULT_CACHE_TIME);
            }
        }
        catch (Exception exception)
        {
            landPromise.Reject(exception.Message);
            hasException = true;
        }
        finally
        {
            if (!hasException)
            {
                landPromise.Resolve(lands);
            }
        }
    }
Esempio n. 2
0
    private void ProcessReceivedLandsData(Promise <List <Land> > landPromise, string jsonValue, string lowerCaseAddress, bool cache)
    {
        try
        {
            LandQueryResultWrapped result = JsonUtility.FromJson <LandQueryResultWrapped>(jsonValue);
            List <Land>            lands  = LandHelper.ConvertQueryResult(result.data, lowerCaseAddress);

            if (cache)
            {
                landQueryCache[lowerCaseAddress] = new QueryLandCache()
                {
                    lands = lands, lastUpdate = Time.unscaledTime
                };
            }

            landPromise.Resolve(lands);
        }
        catch (Exception exception)
        {
            landPromise.Reject(exception.Message);
        }
    }