示例#1
0
文件: AGroup.cs 项目: Deigue/Mutagen
            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) !;
            }
示例#2
0
 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));
 }
示例#3
0
 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));
 }
示例#4
0
        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();
            }
        }
示例#5
0
 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);
 }
示例#6
0
 public static RecordType GetRecordType <T>()
 {
     return((RecordType)LoquiRegistration.GetRegister(typeof(T)) !.GetType().GetField(Mutagen.Bethesda.Internals.Constants.TriggeringRecordTypeMember).GetValue(null));
 }