예제 #1
0
    /// <summary>
    /// Get the item from cache. or do callback and store if not found
    /// </summary>
    /// <param name="index">Index.</param>
    /// <param name="callback">Callback.</param>
    public TItem Get(TIndex index, GetItemCallback callback)
    {
        TItem result = default(TItem);

        if (!_cache.TryGetValue(index, out result))
        {
            result = callback(index);
            _cache.Add(index, result);
        }

        return(result);
    }
예제 #2
0
파일: SftpForm.cs 프로젝트: sy26856/AMShell
        private void getTransferItem(string flag, GetItemCallback callback)
        {
            TransferItem item = null;

            this.BeginInvoke((MethodInvoker) delegate()
            {
                if (flag == "L2R")
                {
                    TransferItem obj = localQueue.Count > 0 ? localQueue.Dequeue() : null;
                    if (null != obj)
                    {
                        if (checkTransferItem(obj))
                        {
                            item = obj;
                            localList.Add(item);
                            callback(item);
                        }
                        else
                        {
                            getTransferItem(flag, callback);
                        }
                    }
                    else
                    {
                        callback(null);
                    }
                }
                else
                {
                    TransferItem obj = remoteQueue.Count > 0 ? remoteQueue.Dequeue() : null;
                    if (null != obj)
                    {
                        if (checkTransferItem(obj))
                        {
                            item = obj;
                            remoteList.Add(item);
                            callback(item);
                        }
                        else
                        {
                            getTransferItem(flag, callback);
                        }
                    }
                    else
                    {
                        callback(null);
                    }
                }
            });
        }
예제 #3
0
    /// <summary>
    /// Retrieve a shop item
    /// </summary>
    /// <param name="itemName"></param>
    /// <param name="callback"></param>

    //Retrieve a Shop Item
    public static void GetShopItem(string itemName, GetItemCallback callback)
    {
        RestClient.Get <ShopItem>($"{databaseURL}shop/{itemName}.json").Then(shopItem => { callback(shopItem); });
    }