ContainsKey() 공개 메소드

Checks whether the given key exists within an array-type node
public ContainsKey ( string key ) : bool
key string The key to look for
리턴 bool
예제 #1
0
        /// <summary>
        /// Adds a non-steam game to the gamelist.
        /// </summary>
        /// <param name="gameId">ID of the game in the steam config file</param>
        /// <param name="gameNode">Node for the game in the steam config file</param>
        /// <param name="launchIds">Dictionary of launch ids (name:launchId)</param>
        /// <param name="newGames">Number of NEW games that have been added to the list</param>
        /// <param name="preferSteamCategories">If true, prefers to use the categories from the steam config if there is a conflict. If false, prefers to use the categories from the existing gamelist.</param>
        /// <returns>True if the game was successfully added</returns>
        private bool IntegrateShortcut( int gameId, VdfFileNode gameNode, StringDictionary launchIds )
        {
            VdfFileNode nodeName = gameNode.GetNodeAt( new string[] { "appname" }, false );
            string gameName = ( nodeName != null ) ? nodeName.NodeString : null;
            // The ID of the created game must be negative
            int newId = -( gameId + 1 );

            // This should never happen, but just in case
            if( Games.ContainsKey( newId ) ) {
                return false;
            }

            //Create the new GameInfo
            GameInfo game = new GameInfo( newId, gameName, this );
            Games.Add( newId, game );

            // Fill in the LaunchString
            game.LaunchString = launchIds[gameName];

            // Fill in categories
            VdfFileNode tagsNode = gameNode.GetNodeAt( new string[] { "tags" }, false );
            foreach( KeyValuePair<string, VdfFileNode> tag in tagsNode.NodeArray ) {
                string tagName = tag.Value.NodeString;
                game.AddCategory( this.GetCategory( tagName ) );
            }

            // Fill in Hidden
            game.Hidden = false;
            if( gameNode.ContainsKey( "hidden" ) ) {
                VdfFileNode hiddenNode = gameNode["hidden"];
                game.Hidden = ( hiddenNode.NodeString == "1" || hiddenNode.NodeInt == 1 );
            }

            return true;
        }
예제 #2
0
        /// <summary>
        /// Adds a non-steam game to the gamelist.
        /// </summary>
        /// <param name="gameId">ID of the game in the steam config file</param>
        /// <param name="gameNode">Node for the game in the steam config file</param>
        /// <param name="oldShortcuts">List of un-matched non-steam games from the gamelist before the update</param>
        /// <param name="launchIds">Dictionary of launch ids (name:launchId)</param>
        /// <param name="newGames">Number of NEW games that have been added to the list</param>
        /// <param name="preferSteamCategories">If true, prefers to use the categories from the steam config if there is a conflict. If false, prefers to use the categories from the existing gamelist.</param>
        /// <returns>True if the game was successfully added</returns>
        private bool IntegrateShortcut( int gameId, VdfFileNode gameNode, List<GameInfo> oldShortcuts, StringDictionary launchIds, ref int newGames, bool preferSteamCategories = true )
        {
            VdfFileNode nodeName = gameNode.GetNodeAt( new string[] { "appname" }, false );
            string gameName = ( nodeName != null ) ? nodeName.NodeString : null;
            // The ID of the created game must be negative
            int newId = -( gameId + 1 );

            // This should never happen, but just in case
            if( Games.ContainsKey( newId ) ) {
                return false;
            }

            GameInfo game = new GameInfo( newId, gameName );
            Games.Add( newId, game );

            game.LaunchString = launchIds[gameName];

            int oldShortcutId = FindMatchingShortcut( gameId, gameNode, oldShortcuts, launchIds );
            bool oldCatSet = ( oldShortcutId != -1 ) && oldShortcuts[oldShortcutId].Categories.Count > 0;
            if( oldShortcutId == -1 ) newGames++;

            VdfFileNode tagsNode = gameNode.GetNodeAt( new string[] { "tags" }, false );
            bool steamCatSet = ( tagsNode != null && tagsNode.NodeType == ValueType.Array && tagsNode.NodeArray.Count > 0 );

            //fill in categories
            if( steamCatSet && ( preferSteamCategories || !oldCatSet ) ) {
                // Fill in categories from the Steam shortcut file
                foreach( KeyValuePair<string, VdfFileNode> tag in tagsNode.NodeArray ) {
                    string tagName = tag.Value.NodeString;
                    game.AddCategory( this.GetCategory( tagName ) );
                }

            } else if( oldShortcutId >= 0 && oldShortcutId < oldShortcuts.Count ) {
                // Fill in categories from the game list
                game.SetCategories( oldShortcuts[oldShortcutId].Categories );
            }

            game.Hidden = false;
            if( gameNode.ContainsKey( "hidden" ) ) {
                VdfFileNode hiddenNode = gameNode["hidden"];
                game.Hidden = ( hiddenNode.NodeString == "1" || hiddenNode.NodeInt == 1 );
            }

            if( oldShortcutId != -1 ) oldShortcuts.RemoveAt( oldShortcutId );
            return true;
        }