Пример #1
0
        public static void InjectMembers(this IVirtualMachine virtualMachine, GamePatch gamePatch, Type type)
        {
            if (((AvailableSinceAttribute)Attribute.GetCustomAttribute(type, typeof(AvailableSinceAttribute)))?.AvailableSince > gamePatch)
            {
                return;
            }

            foreach (var member in type.GetMembers())
            {
                if (((AvailableSinceAttribute)Attribute.GetCustomAttribute(member, typeof(AvailableSinceAttribute)))?.AvailableSince > gamePatch)
                {
                    continue;
                }

                if (member.DeclaringType == type)
                {
                    if (member is FieldInfo field)
                    {
                        virtualMachine.InjectField(field);
                    }
                    else if (member is MethodInfo method)
                    {
                        virtualMachine.InjectMethod(method);
                    }
                }
            }
        }