예제 #1
0
        private static void Execute(IList <string> files, IRebalanceInfoFormatter formatter, IFileSystem fileSystem)
        {
            IDictionary <string, List <ItemInfo> > weaponNames = AlliedModsWiki.GetItemInfos();
            var itemInfoSource  = new ItemInfoSource(weaponNames);
            var classNameSource = new ClassNameSource();
            var transformations = new Dictionary <string, ITransformation <Node> >
            {
                {
                    "tf2rebalance_attributes", new Tf2RebalanceTransformation(itemInfoSource,
                                                                              classNameSource)
                },
                {
                    "Custom Attributes", new CustomAttributesTransformation(itemInfoSource,
                                                                            classNameSource)
                },
            };
            IConverter converter = new CompositeTf2FormatConverter(new ValveFormatParser(), transformations);

            foreach (string filename in files)
            {
                CreateSummary(filename, converter, formatter, fileSystem);
            }

            Log.Information("finished creating summaries for {ConfigFileCount} configs", files.Count);
        }
        static void Main(string[] args)
        {
            Serilog.Log.Logger = new LoggerConfiguration()
                                 .MinimumLevel.Information()
                                 .WriteTo.Console()
                                 .WriteTo.File(new RenderedCompactJsonFormatter(), "log-.clef", restrictedToMinimumLevel: LogEventLevel.Error, rollingInterval: RollingInterval.Day, retainedFileCountLimit: 3)
                                 .Enrich.FromLogContext()
                                 .CreateLogger();

            try
            {
                bool exitSilently = true;
                if (args.Length == 0)
                {
                    exitSilently = false;
                    Console.WriteLine("no argument provided");
                    Console.Write("enter filename: ");
                    string input = Console.ReadLine();

                    Log.Information("manually provided filename: {ManuallyProvidedFilename}", input);
                    args = new[] { input };
                }

                IDictionary <string, List <ItemInfo> > weaponNames = AlliedModsWiki.GetItemInfos();
                Converter converter             = new Converter(weaponNames);
                IRebalanceInfoFormater formater = new RebalanceInfoRtfFormater();

                foreach (string filename in args)
                {
                    CreateSummary(filename, converter, formater);
                }

                Log.Information("finished creating summaries for {ConfigFileCount} configs", args.Length);

                if (!exitSilently)
                {
                    Console.WriteLine("press enter to exit");
                    Console.ReadLine();
                }
            }
            catch (Exception e)
            {
                Log.Fatal(e, "fatal exception");
                Console.WriteLine("press enter to exit");
                Console.ReadLine();
                throw;
            }
            finally
            {
                Serilog.Log.CloseAndFlush();
            }
        }