static GroupRecordTypeGetter() { var regis = LoquiRegistration.GetRegister(typeof(T)); if (regis == null) { throw new ArgumentException(); } GRUP_RECORD_TYPE = (RecordType)regis.ClassType.GetField(Mutagen.Bethesda.Internals.Constants.GrupRecordTypeMember) !.GetValue(null) !; }
public static RecordException Enrich <TMajor>(Exception ex, FormKey?formKey, string?edid, ModKey?modKey = null) where TMajor : IMajorRecordCommonGetter { return(Enrich( ex, formKey, LoquiRegistration.GetRegister(typeof(TMajor)).ClassType, edid, modKey)); }
public static RecordException Create <TMajor>(string message, FormKey?formKey, string?edid, ModKey?modKey = null, Exception?innerException = null) where TMajor : IMajorRecordCommonGetter { return(Create( message: message, formKey: formKey, recordType: LoquiRegistration.GetRegister(typeof(TMajor)).ClassType, modKey: modKey, edid: edid, innerException: innerException)); }
private static CreateFunc GetCreateFunc() { var regis = LoquiRegistration.GetRegister(typeof(T)); if (regis == null) { throw new ArgumentException(); } var className = $"{regis.Namespace}.Internals.{regis.Name}BinaryOverlay"; var tType = regis.ClassType.Assembly.GetType(className) !; var method = tType.GetMethods() .Where((methodInfo) => methodInfo.Name.Equals($"{regis.Name}Factory")) .Where((methodInfo) => methodInfo.IsStatic && methodInfo.IsPublic) .Where((methodInfo) => { var param = methodInfo.GetParameters(); if (param.Length != 3) { return(false); } if (!param[0].ParameterType.Equals(typeof(OverlayStream))) { return(false); } if (!param[1].ParameterType.Equals(typeof(BinaryOverlayFactoryPackage))) { return(false); } if (!param[2].ParameterType.Equals(typeof(RecordTypeConverter))) { return(false); } return(true); }) .FirstOrDefault(); if (method != null) { return(DelegateBuilder.BuildDelegate <CreateFunc>(method)); } else { throw new ArgumentException(); } }
private IReadOnlyCache <IModContext <TMod, IMajorRecordCommon, IMajorRecordCommonGetter>, FormKey> GetContextCache(Type type) { if (!_contexts.TryGetValue(type, out var cache)) { if (type.Equals(typeof(IMajorRecordCommon)) || type.Equals(typeof(IMajorRecordCommonGetter))) { cache = ConstructContextCache(type); _contexts[typeof(IMajorRecordCommon)] = cache; _contexts[typeof(IMajorRecordCommonGetter)] = cache; } else if (LoquiRegistration.TryGetRegister(type, out var registration)) { cache = ConstructContextCache(type); _contexts[registration.ClassType] = cache; _contexts[registration.GetterType] = cache; _contexts[registration.SetterType] = cache; if (registration.InternalGetterType != null) { _contexts[registration.InternalGetterType] = cache; } if (registration.InternalSetterType != null) { _contexts[registration.InternalSetterType] = cache; } } else { var interfaceMappings = LinkInterfaceMapping.InterfaceToObjectTypes(_sourceMod.GameRelease.ToCategory()); if (!interfaceMappings.TryGetValue(type, out var objs)) { throw new ArgumentException($"A lookup was queried for an unregistered type: {type.Name}"); } var majorRecords = new Cache <IModContext <TMod, IMajorRecordCommon, IMajorRecordCommonGetter>, FormKey>(x => x.Record.FormKey); foreach (var objType in objs) { majorRecords.Set(GetContextCache(LoquiRegistration.GetRegister(objType).GetterType).Items); } _contexts[type] = majorRecords; cache = majorRecords; } } return(cache); }
public static RecordType GetRecordType <T>() { return((RecordType)LoquiRegistration.GetRegister(typeof(T)) !.GetType().GetField(Mutagen.Bethesda.Internals.Constants.TriggeringRecordTypeMember).GetValue(null)); }