コード例 #1
0
ファイル: Program.cs プロジェクト: namralkeeg/PexNinja
        private static IPex GetPex(string fileName, string game)
        {
            if (fileName == null)
            {
                throw new ArgumentNullException("fileName");
            }
            if (game == null)
            {
                throw new ArgumentNullException("game");
            }
            Contract.EndContractBlock();

            IPex pex = null;

            pex = PexFactory.GetPex(game);
            if ((pex != null) && File.Exists(fileName))
            {
                using (var fs = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
                {
                    pex.Read(fs);
                }
            }

            return(pex);
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: namralkeeg/PexNinja
        static void Main(string[] args)
        {
            var optionsHandler = new OptionsHandler();

            if (!optionsHandler.ProcessOptions(args))
            {
                optionsHandler.ShowHelp();
                return;
            }

            if (optionsHandler.ProgramOptions.ShowVersion)
            {
                optionsHandler.ShowVersion();
                Console.WriteLine();
                if (!optionsHandler.ProgramOptions.ShowHelp)
                {
                    return;
                }
            }

            if (optionsHandler.ProgramOptions.ShowHelp)
            {
                optionsHandler.ShowHelp();
                return;
            }

            var entries = GetValidFiles(optionsHandler.ProgramOptions);

            foreach (var entry in entries)
            {
                Console.WriteLine(entry);
                if (optionsHandler.ProgramOptions.Game == null)
                {
                    using (IPex pex = GetPex(entry))
                    {
                        if (pex != null)
                        {
                            Console.WriteLine(pex.ToString());
                        }
                    }
                }
                else
                {
                    using (IPex pex = GetPex(entry, optionsHandler.ProgramOptions.Game))
                    {
                        if (pex != null)
                        {
                            Console.WriteLine(pex.ToString());
                        }
                    }
                }
            }
        }