public void CompileAllModels() { if (_constants.Debug) { _logger.Log(LogType.Debug, $"Attempting to compile {_definitions.Count} d2o models to C# class..."); } var elapsedCompiling = ActionTimer.Bench(() => { foreach (var file in _files) { foreach (var classDef in file.LocalClassDefinitions.Unpacked) { var elapsed = ActionTimer.Bench(() => new D2OModelCompiler(file.LocalClassDefinitions.Unpacked, classDef).Compile()); if (_constants.Debug) { _logger.Log(LogType.Debug, $"{classDef.Name}.cs successfully compiled in {elapsed.Milliseconds}ms"); } } } }); _logger.Log(LogType.Info, $"{_definitions.Count} d2o models succcessfully compiled to C# class in {elapsedCompiling.Milliseconds}ms"); }
public void Load(string[] d2OPaths) { if (_constants.Debug) { _logger.Log(LogType.Debug, $"Attempting to load {d2OPaths.Length} d2o files..."); } var fileValidator = new FileNameValidation(".d2o"); if (d2OPaths.Any(path => !fileValidator.IsValid(Path.GetFileName(path)))) { throw new InvalidOperationException("file aren't .d2o"); } _files = new List <ID2OFile>(d2OPaths.Length); _definitions = new List <D2OClassDefinition>(); var elapsed = ActionTimer.Bench(() => _parseAllClassDefinitions(d2OPaths)); _logger.Log(LogType.Info, $"{d2OPaths.Length} .d2o files with {_definitions.Count} class definitions parsed in {elapsed.Milliseconds}ms"); }
static void Main(string[] args) { Console.Title = "Andromeda data builder"; AppConstants appConstants; while (!_tryParseArgs(args, out appConstants)) // todo: implements logic { _tryParseArgs(AskInput(), out appConstants); } var container = Startup.Configure(new ContainerBuilder(), appConstants); var logger = container.GetInstance <Logger>(); try { var files = Directory.GetFiles(appConstants.D2OPath, "*.d2o"); var elapsed = ActionTimer.Bench(() => { var d2OManager = new D2OManager(); d2OManager.Load(files); d2OManager.CompileAllModels(); }); logger.Log(LogType.Info, $"Execution took {elapsed:g}"); } catch (Exception e) { logger.Log(LogType.Fatal, e.ToString()); } finally { logger.Save(); } Console.WriteLine(); Console.WriteLine("--- Press any key to exit"); Console.ReadLine(); }