예제 #1
0
        // wrapped method calls to ensure the class is not initialized if unavailable
        private static FastReflectionDelegate GetFastDelegateForCecil(MethodBase method, bool directBoxValueAccess, bool forceNonVirtCall)
        {
            try
            {
                return(CecilFastReflectionHelper.CreateFastDelegate(method, directBoxValueAccess, forceNonVirtCall));
            }
            catch (Exception e1)
            {
                try
                {
                    XuaLogger.Common.Warn(e1, "Failed creating fast reflection delegate through with cecil. Retrying with reflection emit...");

                    return(ReflectionEmitFastReflectionHelper.CreateFastDelegate(method, directBoxValueAccess, forceNonVirtCall));;
                }
                catch (Exception e2)
                {
                    XuaLogger.Common.Warn(e2, "Failed creating fast reflection delegate through with reflection emit. Falling back to standard reflection...");

                    return((target, args) => method.Invoke(target, args));
                }
            }
        }
예제 #2
0
        private static Action <T, F> CreateFastFieldSetterForCecil <T, F>(FieldInfo fieldInfo)
        {
            try
            {
                return(CecilFastReflectionHelper.CreateFastFieldSetter <T, F>(fieldInfo));
            }
            catch (Exception e1)
            {
                try
                {
                    XuaLogger.Common.Warn(e1, "Failed creating fast reflection delegate through with cecil. Retrying with reflection emit...");

                    return(ReflectionEmitFastReflectionHelper.CreateFastFieldSetter <T, F>(fieldInfo));
                }
                catch (Exception e2)
                {
                    XuaLogger.Common.Warn(e2, "Failed creating fast reflection delegate through with reflection emit. Falling back to standard reflection...");

                    return((target, value) => fieldInfo.SetValue(target, value));
                }
            }
        }
예제 #3
0
 private static Action <T, F> CreateFastFieldSetterForCecil <T, F>(FieldInfo fieldInfo)
 {
     return(CecilFastReflectionHelper.CreateFastFieldSetter <T, F>(fieldInfo));
 }
예제 #4
0
 // wrapped method calls to ensure the class is not initialized if unavailable
 private static FastReflectionDelegate GetFastDelegateForCecil(MethodBase method, bool directBoxValueAccess, bool forceNonVirtCall)
 {
     return(CecilFastReflectionHelper.CreateFastDelegate(method, directBoxValueAccess, forceNonVirtCall));;
 }