static ComponentDatabase() { Metaclasses = ReflectionUtility.GetNonAbstractTypes(typeof(IComponentMetaclass)) .Select(type => (IComponentMetaclass)Activator.CreateInstance(type)) .ToDictionary(metaclass => metaclass.ComponentId, metaclass => metaclass); ComponentsToIds = Metaclasses.ToDictionary(pair => pair.Value.Data, pair => pair.Key); SnapshotsToIds = Metaclasses.ToDictionary(pair => pair.Value.Snapshot, pair => pair.Key); }
static ComponentDatabase() { Metaclasses = ReflectionUtility.GetNonAbstractTypes(typeof(IComponentMetaclass)) .Select(type => (IComponentMetaclass)Activator.CreateInstance(type)) .ToDictionary(metaclass => metaclass.ComponentId, metaclass => metaclass); ComponentsToIds = Metaclasses.ToDictionary(pair => pair.Value.Data, pair => pair.Key); SnapshotsToIds = Metaclasses.ToDictionary(pair => pair.Value.Snapshot, pair => pair.Key); RequestsToCommandMetaclass = Metaclasses .SelectMany(pair => pair.Value.Commands.Select(cmd => (cmd.Request, cmd))) .ToDictionary(pair => pair.Request, pair => pair.cmd); ReceivedRequestsToCommandMetaclass = Metaclasses .SelectMany(pair => pair.Value.Commands.Select(cmd => (cmd.ReceivedRequest, cmd))) .ToDictionary(pair => pair.ReceivedRequest, pair => pair.cmd); }