コード例 #1
0
        public void IncrementPlusCodeData(string plusCode, string key, double changeAmount, double?expirationTimer = null)
        {
            if (!DataCheck.IsInBounds(cache.Get <IPreparedGeometry>("serverBounds"), OpenLocationCode.DecodeValid(plusCode)))
            {
                return;
            }

            PerformanceTracker pt      = new PerformanceTracker("IncrementPlusCodeData");
            string             lockKey = plusCode + key;

            locks.TryAdd(lockKey, new ReaderWriterLockSlim());
            var thisLock = locks[lockKey];

            thisLock.EnterWriteLock();
            var    data = GenericData.GetAreaData(plusCode, key);
            double val  = 0;

            Double.TryParse(data.ToString(), out val);
            val += changeAmount;
            GenericData.SetAreaData(plusCode, key, val.ToString(), expirationTimer);
            thisLock.ExitWriteLock();

            if (thisLock.WaitingWriteCount == 0)
            {
                locks.TryRemove(lockKey, out thisLock);
            }

            pt.Stop();
        }
コード例 #2
0
        public void GetPlusCodeData(string plusCode, string key)
        {
            if (!DataCheck.IsInBounds(cache.Get <IPreparedGeometry>("serverBounds"), OpenLocationCode.DecodeValid(plusCode)))
            {
                return;
            }

            var data = GenericData.GetAreaData(plusCode, key); //TODO: this requires writing bytes directly to Response.BodyWriter for all other, similar functions.

            Response.BodyWriter.WriteAsync(data);
            Response.CompleteAsync();
            return;
        }