コード例 #1
0
        public async void RefreshAsync()
        {
            while (true)
            {
                try
                {
                    using (var httpClient = new HttpClient())
                    {
                        FoodClient foodClient = new FoodClient(httpClient);
                        Task <ICollection <Food> > allFoodTask = foodClient.GetAllFoodAsync();
                        FoodList.Clear();
                        foreach (var item in await allFoodTask)
                        {
                            FoodList.Add(item);
                        }

                        CategoryClient categoryClient = new CategoryClient(httpClient);
                        Task <ICollection <Category> > allCategoryTask = categoryClient.GetAllCategoryAsync();
                        CategoryList.Clear();
                        foreach (var item in await allCategoryTask)
                        {
                            CategoryList.Add(item);
                        }

                        StorageClient storageClient = new StorageClient(httpClient);
                        Task <ICollection <Storage> > allStorageTask = storageClient.GetAllStorageAsync();
                        StorageList.Clear();
                        foreach (var item in await allStorageTask)
                        {
                            StorageList.Add(item);
                        }

                        SlotClient slotClient = new SlotClient(httpClient);
                        Task <ICollection <Slot> > allSlotTask = slotClient.GetAllSlotAsync();
                        SlotList.Clear();
                        foreach (var item in await allSlotTask)
                        {
                            SlotList.Add(item);
                        }
                    }
                    return;
                }
                catch
                {
                    Thread.Sleep(500);
                }
            }
        }
コード例 #2
0
        /// <summary>
        /// Removes all assets
        /// </summary>
        static public void ClearAssets()
        {
            Trace.WriteDebugLine("[ResourceManager] ClearAssets()");


            lock (BinaryLock)
            {
                foreach (RegisteredAsset ra in RegisteredAssets)
                {
                    ra.Clear();
                }
            }


            // Remove all storages
            foreach (StorageBase storage in StorageList)
            {
                storage.Dispose();
            }
            StorageList.Clear();
        }
コード例 #3
0
        /// <summary>
        /// Initialize each providers
        /// </summary>
        static public void Dispose()
        {
            Trace.WriteDebugLine("[ResourceManager] Dispose()");


            if (TileSet.InUse != null && TileSet.InUse.Count > 0)
            {
                Trace.WriteLine("{0} TileSet remaining...", TileSet.InUse.Count);
                foreach (TileSet ts in TileSet.InUse)
                {
                    Trace.WriteLine(" -> \"" + ts.Name + "\"");
                }
            }

            EraseSharedAssets();


            foreach (StorageBase storage in StorageList)
            {
                storage.Dispose();
            }
            StorageList.Clear();
        }
コード例 #4
0
        private PrivacyQueue FetchQueue(string symbol)
        {
            StorageList list = _queues.Get <string, StorageList>(symbol);

            PrivacyQueue queue;

            var count = list.Count();

            if (count > 0)
            {
                var last = list.Get <PrivacyQueue>(count - 1);
                if (last.addresses.Count() < last.size)
                {
                    return(last);
                }
            }

            var id      = (uint)(count + 1);
            var baseKey = $"{symbol}.{id}";

            var addrKey     = $"{baseKey}.addr".AsByteArray();
            var addressList = new StorageList(addrKey, Runtime.ChangeSet);

            addressList.Clear();

            var ringKey  = $"{baseKey}.ring".AsByteArray();
            var ringList = new StorageList(addrKey, Runtime.ChangeSet);

            ringList.Clear();

            queue = new PrivacyQueue()
            {
                addresses = addressList, signatures = ringList, ID = id, size = 3
            };
            list.Add(queue);
            return(queue);
        }