using System; using System.Collections.Generic; namespace Server.Commands; public sealed record ExtractedObject( Type Type, string Entity, string Category, LeanMetadata Lean, List Ctors, List Properties, List Opl, string BaseType ); public static class ObjectCacheBuilder { public static (ObjectIndexFile index, Dictionary> chunks) Build( IReadOnlyList objects, string generatedUtc ) { var index = new ObjectIndexFile { GeneratedUtc = generatedUtc }; var chunks = new Dictionary>(); foreach (var obj in objects) { var chunkKey = ObjectNaming.ChunkKey(obj.Category); index.Objects.Add( new ObjectIndexEntry { Type = obj.Type.Name, Entity = obj.Entity, Category = obj.Category, Chunk = chunkKey, ItemID = obj.Lean.ItemID, Hue = obj.Lean.Hue, Name = obj.Lean.Name, Cliloc = obj.Lean.Cliloc } ); if (!chunks.TryGetValue(chunkKey, out var chunk)) { chunks[chunkKey] = chunk = new Dictionary(); } chunk[obj.Type.Name] = new ObjectDetail { BaseType = obj.BaseType, Ctors = obj.Ctors, Properties = obj.Properties, Opl = obj.Opl }; } return (index, chunks); } }