Exemplo n.º 1
0
        public bool FindApp(string search, out uint appId, bool gamesOnly)
        {
            appId = 0;

            var appMatches = appNameCache
                             .Where(kvp => kvp.Key.IndexOf(search, StringComparison.OrdinalIgnoreCase) != -1)
                             .ToList();

            if (appMatches.Count == 0)
            {
                return(false);
            }

            var appList = appMatches.Select(kvp => kvp.Value);

            if (gamesOnly)
            {
                // todo: appease azuisleet with something better than searching for only games
                appList = appList.Where(app => app.IsGame);
            }

            AppCacheEntry searchResult = appList.FirstOrDefault();

            if (searchResult != null)
            {
                appId = searchResult.AppID;
                return(true);
            }

            return(false);
        }
Exemplo n.º 2
0
        public bool GetAppInfo(uint appId, out KeyValue appInfo)
        {
            appInfo = KeyValue.LoadAsText(GetAppCachePath(appId));

            // cache off the name
            if (appInfo != null)
            {
                string name = appInfo["common"]["name"].AsString();
                string type = appInfo["common"]["type"].AsString();

                bool isGame = string.Equals(type, "game", StringComparison.OrdinalIgnoreCase);

                if (name != null)
                {
                    appNameCache[name] = new AppCacheEntry {
                        AppID = appId, IsGame = isGame
                    };
                }
            }

            return(appInfo != null);
        }
        public bool GetAppInfo( uint appId, out KeyValue appInfo )
        {
            appInfo = KeyValue.LoadAsText( GetAppCachePath( appId ) );

            // cache off the name
            if ( appInfo != null )
            {
                string name = appInfo[ "common" ][ "name" ].AsString();
                string type = appInfo[ "common" ][ "type" ].AsString();

                bool isGame = string.Equals( type, "game", StringComparison.OrdinalIgnoreCase );

                if ( name != null )
                {
                    appNameCache[ name ] = new AppCacheEntry { AppID = appId, IsGame = isGame };
                }
            }

            return appInfo != null;
        }