Exemple #1
0
        public async Task <bool> Add(ICacheChip <T> chip, params object[] contents)
        {
            T content = (T)contents[0];

            if (_cacheIndexs.ContainsKey(chip.HashKey))
            {
                _cacheIndexs[chip.HashKey] = chip;
            }
            else
            {
                _cacheIndexs.Add(chip.HashKey, chip);
                await chip.SaveCacheData(content);
            }
            return(true);
        }
        public async Task <bool> Add(ICacheChip <BitmapImage> chip, params object[] contents)
        {
            //lock (this)
            {
                string url = (string)contents[0];
                if (_cacheIndexs.ContainsKey(chip.HashKey))
                {
                    _cacheIndexs[chip.HashKey] = chip;
                }
                else
                {
                    _cacheIndexs.Add(chip.HashKey, chip);
                }

                await chip.SaveCacheData(url);
            }

            return(true);
        }
        public async Task <bool> Replace(ICacheChip <BitmapImage> chip, params object[] contents)
        {
            if (contents.Length < 2)
            {
                throw new ArgumentException();
            }

            if (this._cacheIndexs.ContainsKey(chip.HashKey))
            {
                _cacheIndexs.Remove(chip.HashKey);
            }

            ICacheChip <BitmapImage> newchip = contents[0] as ICacheChip <BitmapImage>;
            string url = contents[1] as string;

            _cacheIndexs.Add(chip.HashKey, newchip);

            await newchip.SaveCacheData(url);

            return(true);
        }
Exemple #4
0
        public async Task <bool> Replace(ICacheChip <T> chip, params object[] contents)
        {
            if (contents.Length < 2)
            {
                throw new ArgumentException();
            }

            if (this._cacheIndexs.ContainsKey(chip.HashKey))
            {
                _cacheIndexs.Remove(chip.HashKey);
            }

            ICacheChip <T> newchip = contents[0] as ICacheChip <T>;
            T content = (T)contents[0];

            _cacheIndexs.Add(chip.HashKey, newchip);

            await newchip.SaveCacheData(content);

            return(true);
        }