Esempio n. 1
0
        public UserInventoryAssetDescription GetAssetDescription(UserInventoryAsset asset)
        {
            if (_descriptions == null || asset == null)
            {
                return(null);
            }

            return(_descriptions.FirstOrDefault(description => description.DoesDescribe(asset)));
        }
Esempio n. 2
0
        public async Task <UserInventoryAssetDescription> GetAssetDescription(UserInventoryAsset asset)
        {
            UserInventoryApp        inventoryApp;
            UserInventoryAppContext appContext;

            lock (_inventoryApps)
            {
                inventoryApp = _inventoryApps.FirstOrDefault(app => app.AppId == asset.AppId);

                if (inventoryApp == null)
                {
                    inventoryApp = new UserInventoryApp(asset.AppId);
                    _inventoryApps.Add(inventoryApp);
                }

                appContext = inventoryApp.Contexts.FirstOrDefault(context => context.ContextId == asset.ContextId);

                if (appContext == null)
                {
                    appContext = new UserInventoryAppContext(asset.ContextId);
                    inventoryApp.Update(
                        new UserInventoryApp(inventoryApp.AppId, null, null, new[] { appContext }, null, null, null)
                        );
                }
            }

            lock (_inventoryCache)
            {
                if (!_inventoryCache.ContainsKey(inventoryApp.AppId))
                {
                    _inventoryCache.Add(inventoryApp.AppId, new Dictionary <long, UserAppInventory>());
                }
            }

            await FillAppContextCache(inventoryApp, appContext).ConfigureAwait(false);

            lock (_inventoryCache)
            {
                return(_inventoryCache[inventoryApp.AppId]
                       .Where(pair => pair.Key == appContext.ContextId)
                       .SelectMany(pair => pair.Value.AssetDescriptions)
                       .FirstOrDefault(description => description.DoesDescribe(asset)));
            }
        }
Esempio n. 3
0
 public UserInventoryAssetDescription GetAssetDescription(UserInventoryAsset asset)
 {
     return(_receiptAssets.FirstOrDefault(receiptAsset => receiptAsset.ToSteamInventoryAsset().Equals(asset))
            ?.ToSteamAssetDescription());
 }