static SecuredReflectionMethods() { if (!SecuredReflection.HasReflectionPermission) { if (!ProfilerInterceptor.IsProfilerAttached) { ProfilerInterceptor.ThrowElevatedMockingException(); } ProfilerInterceptor.CreateDelegateFromBridge("ReflectionInvoke", out Invoke); ProfilerInterceptor.CreateDelegateFromBridge("ReflectionGetProperty", out GetProperty); ProfilerInterceptor.CreateDelegateFromBridge("ReflectionSetProperty", out SetProperty); ProfilerInterceptor.CreateDelegateFromBridge("ReflectionGetField", out GetField); ProfilerInterceptor.CreateDelegateFromBridge("ReflectionSetField", out SetField); } else { Invoke = (method, instance, args) => method.Invoke(instance, args); GetProperty = (prop, instance, indexArgs) => prop.GetValue(instance, indexArgs); SetProperty = (prop, instance, value, indexArgs) => prop.SetValue(instance, value, indexArgs); GetField = (field, instance) => field.GetValue(instance); SetField = (field, instance, value) => field.SetValue(instance, value); } }