private void ImportKitFromFile(DataTreeNodeViewModel kitNode) { string?file = ViewServices.ShowOpenFileDialog(FileFilters.KitFiles); if (file is null) { return; } object loaded; try { loaded = ProtoIo.LoadModel(file, Logger); } catch (Exception ex) { Logger.LogError($"Error loading {file}", ex); return; } if (!(loaded is Kit kit)) { Logger.LogError("Loaded file was not a kit"); return; } if (!kit.Schema.Identifier.Equals(Module.Schema.Identifier)) { Logger.LogError($"Kit was from {kit.Schema.Identifier.Name}; this module is {Module.Schema.Identifier.Name}"); return; } Module.ImportKit(kit, kitNode.KitNumber !.Value); }
static void Main(string[] args) { string file = args[0]; for (int i = 0; i < 10; i++) { var model = (Module)Timing.DebugConsoleLogTiming("Loaded model", () => ProtoIo.LoadModel(file, NullLogger.Instance)); var containers = model.Schema.PhysicalRoot.DescendantsAndSelf().OfType <FieldContainer>().ToList(); Timing.DebugConsoleLogTiming("Populated dictionaries", () => containers.ForEach(fc => fc.GetFieldOrNull("".AsSpan()))); } }