static void Main(string[] args) { var stackOfValues = new Stack<string>(); GetInitialValuesFromArgs(args, ref stackOfValues); var demoSet1 = new Set<string>(stackOfValues.ToArray()); Console.WriteLine(demoSet1.ToString()); var demoSet3 = new SortedSet(stackOfValues.ToArray()); Console.WriteLine(demoSet3.ToString()); Console.ReadKey(); }
/// <summary> /// Loads in games from a VDF node containing a list of games. /// Any games in the node not found in the game list will be added to the gamelist. /// If a game in the node has a tags subnode, the "favorite" field will be overwritten. /// If a game in the node has a category set, it will overwrite any categories in the gamelist. /// If a game in the node does NOT have a category set, the category in the gamelist will NOT be cleared. /// </summary> /// <param name="appsNode">Node containing the game nodes</param> /// <param name="ignore">Set of games to ignore</param> /// <returns>Number of games loaded</returns> private int IntegrateGamesFromVdf( VdfFileNode appsNode, SortedSet<int> ignore, bool ignoreDlc ) { int loadedGames = 0; Dictionary<string, VdfFileNode> gameNodeArray = appsNode.NodeArray; if( gameNodeArray != null ) { foreach( KeyValuePair<string, VdfFileNode> gameNodePair in gameNodeArray ) { int gameId; if( int.TryParse( gameNodePair.Key, out gameId ) ) { if( ( ignore != null && ignore.Contains( gameId ) ) || ( ignoreDlc && Program.GameDB.IsDlc( gameId ) ) ) { Program.Logger.Write( LoggerLevel.Verbose, GlobalStrings.GameData_SkippedProcessingGame, gameId ); continue; } if( gameNodePair.Value != null && gameNodePair.Value.ContainsKey( "tags" ) ) { SortedSet<Category> cats = new SortedSet<Category>(); loadedGames++; VdfFileNode tagsNode = gameNodePair.Value["tags"]; Dictionary<string, VdfFileNode> tagArray = tagsNode.NodeArray; if( tagArray != null ) { foreach( VdfFileNode tag in tagArray.Values ) { string tagName = tag.NodeString; if( tagName != null ) { Category c = GetCategory( tagName ); if( c != null ) cats.Add( c ); } } } bool hidden = false; if( gameNodePair.Value.ContainsKey( "hidden" ) ) { VdfFileNode hiddenNode = gameNodePair.Value["hidden"]; hidden = ( hiddenNode.NodeString == "1" || hiddenNode.NodeInt == 1 ); } // Add the game to the list if it doesn't exist already if( !Games.ContainsKey( gameId ) ) { GameInfo newGame = new GameInfo( gameId, string.Empty ); Games.Add( gameId, newGame ); newGame.Name = Program.GameDB.GetName( gameId ); Program.Logger.Write( LoggerLevel.Verbose, GlobalStrings.GameData_AddedNewGame, gameId, newGame.Name ); } if( cats.Count > 0 ) { this.SetGameCategories( gameId, cats, false ); } Games[gameId].Hidden = hidden; //TODO: Don't think SortedSet.ToString() does what I hope Program.Logger.Write( LoggerLevel.Verbose, GlobalStrings.GameData_ProcessedGame, gameId, ( cats.Count == 0 ) ? "~" : cats.ToString() ); } } } } return loadedGames; }