本文整理汇总了C#中System.Reflection.Binder.EnsureNotCustomBinder方法的典型用法代码示例。如果您正苦于以下问题:C# Binder.EnsureNotCustomBinder方法的具体用法?C# Binder.EnsureNotCustomBinder怎么用?C# Binder.EnsureNotCustomBinder使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Reflection.Binder
的用法示例。
在下文中一共展示了Binder.EnsureNotCustomBinder方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Invoke
public sealed override object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
{
binder.EnsureNotCustomBinder();
if (parameters == null)
parameters = Array.Empty<Object>();
Object ctorAllocatedObject = this.MethodInvoker.Invoke(null, parameters);
return ctorAllocatedObject;
}
示例2: Invoke
public sealed override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
{
#if ENABLE_REFLECTION_TRACE
if (ReflectionTrace.Enabled)
ReflectionTrace.MethodBase_Invoke(this, obj, parameters);
#endif
binder.EnsureNotCustomBinder();
if (parameters == null)
parameters = Array.Empty<Object>();
MethodInvoker methodInvoker;
try
{
methodInvoker = this.MethodInvoker;
}
catch (Exception)
{
//
// Project N compat note: On the desktop, ConstructorInfo.Invoke(Object[]) specifically forbids invoking static constructors (and
// for us, that check is embedded inside the MethodInvoker property call.) Howver, MethodBase.Invoke(Object, Object[]) allows it. This was
// probably an oversight on the desktop. We choose not to support this loophole on Project N for the following reasons:
//
// 1. The Project N toolchain aggressively replaces static constructors with static initialization data whenever possible.
// So the static constructor may no longer exist.
//
// 2. Invoking the static constructor through Reflection is not very useful as it invokes the static constructor whether or not
// it was already run. Since static constructors are specifically one-shot deals, this will almost certainly mess up the
// type's internal assumptions.
//
if (this.IsStatic)
throw new PlatformNotSupportedException(SR.Acc_NotClassInit);
throw;
}
return methodInvoker.Invoke(obj, parameters);
}
示例3: SetValue
public sealed override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
{
#if ENABLE_REFLECTION_TRACE
if (ReflectionTrace.Enabled)
ReflectionTrace.FieldInfo_SetValue(this, obj, value);
#endif
binder.EnsureNotCustomBinder();
FieldAccessor fieldAccessor = this.FieldAccessor;
fieldAccessor.SetField(obj, value);
}
示例4: SetValue
public sealed override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
{
#if ENABLE_REFLECTION_TRACE
if (ReflectionTrace.Enabled)
ReflectionTrace.PropertyInfo_SetValue(this, obj, value, index);
#endif
binder.EnsureNotCustomBinder();
if (_lazySetterInvoker == null)
{
if (!CanWrite)
throw new ArgumentException();
_lazySetterInvoker = Setter.GetUncachedMethodInvoker(Array.Empty<RuntimeTypeInfo>(), this);
}
Object[] arguments;
if (index == null)
{
arguments = new Object[] { value };
}
else
{
arguments = new Object[index.Length + 1];
for (int i = 0; i < index.Length; i++)
{
arguments[i] = index[i];
}
arguments[index.Length] = value;
}
_lazySetterInvoker.Invoke(obj, arguments);
}
示例5: GetValue
public sealed override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
{
#if ENABLE_REFLECTION_TRACE
if (ReflectionTrace.Enabled)
ReflectionTrace.PropertyInfo_GetValue(this, obj, index);
#endif
binder.EnsureNotCustomBinder();
if (_lazyGetterInvoker == null)
{
if (!CanRead)
throw new ArgumentException();
_lazyGetterInvoker = Getter.GetUncachedMethodInvoker(Array.Empty<RuntimeTypeInfo>(), this);
}
if (index == null)
index = Array.Empty<Object>();
return _lazyGetterInvoker.Invoke(obj, index);
}
示例6: Invoke
public sealed override object Invoke(BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
{
#if ENABLE_REFLECTION_TRACE
if (ReflectionTrace.Enabled)
ReflectionTrace.ConstructorInfo_Invoke(this, parameters);
#endif
binder.EnsureNotCustomBinder();
if (parameters == null)
parameters = Array.Empty<Object>();
// Most objects are allocated by NewObject and their constructors return "void". But in many frameworks,
// there are "weird" cases (e.g. String) where the constructor must do both the allocation and initialization.
// Reflection.Core does not hardcode these special cases. It's up to the ExecutionEnvironment to steer
// us the right way by coordinating the implementation of NewObject and MethodInvoker.
Object newObject = ReflectionCoreExecution.ExecutionEnvironment.NewObject(this.DeclaringType.TypeHandle);
Object ctorAllocatedObject = this.MethodInvoker.Invoke(newObject, parameters);
return newObject != null ? newObject : ctorAllocatedObject;
}
示例7: SetValue
public sealed override void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
{
#if ENABLE_REFLECTION_TRACE
if (ReflectionTrace.Enabled)
ReflectionTrace.PropertyInfo_SetValue(this, obj, value, index);
#endif
binder.EnsureNotCustomBinder();
if (_lazySetterInvoker == null)
{
MethodHandle setterMethodHandle;
if (!GetAccessor(MethodSemanticsAttributes.Setter, out setterMethodHandle))
throw new ArgumentException();
MethodAttributes setterMethodAttributes = setterMethodHandle.GetMethod(_reader).Flags;
_lazySetterInvoker = ReflectionCoreExecution.ExecutionEnvironment.GetMethodInvoker(_reader, _contextTypeInfo, setterMethodHandle, Array.Empty<RuntimeTypeInfo>(), this);
}
Object[] arguments;
if (index == null)
{
arguments = new Object[] { value };
}
else
{
arguments = new Object[index.Length + 1];
for (int i = 0; i < index.Length; i++)
{
arguments[i] = index[i];
}
arguments[index.Length] = value;
}
_lazySetterInvoker.Invoke(obj, arguments);
}
示例8: GetValue
public sealed override object GetValue(object obj, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
{
#if ENABLE_REFLECTION_TRACE
if (ReflectionTrace.Enabled)
ReflectionTrace.PropertyInfo_GetValue(this, obj, index);
#endif
binder.EnsureNotCustomBinder();
if (_lazyGetterInvoker == null)
{
MethodHandle getterMethodHandle;
if (!GetAccessor(MethodSemanticsAttributes.Getter, out getterMethodHandle))
throw new ArgumentException();
MethodAttributes getterMethodAttributes = getterMethodHandle.GetMethod(_reader).Flags;
_lazyGetterInvoker = ReflectionCoreExecution.ExecutionEnvironment.GetMethodInvoker(_reader, _contextTypeInfo, getterMethodHandle, Array.Empty<RuntimeTypeInfo>(), this);
}
if (index == null)
index = Array.Empty<Object>();
return _lazyGetterInvoker.Invoke(obj, index);
}
示例9: Invoke
public sealed override object Invoke(object obj, BindingFlags invokeAttr, Binder binder, object[] parameters, CultureInfo culture)
{
#if ENABLE_REFLECTION_TRACE
if (ReflectionTrace.Enabled)
ReflectionTrace.MethodBase_Invoke(this, obj, parameters);
#endif
binder.EnsureNotCustomBinder();
if (parameters == null)
parameters = Array.Empty<Object>();
MethodInvoker methodInvoker = this.MethodInvoker;
object result = methodInvoker.Invoke(obj, parameters);
System.Diagnostics.DebugAnnotations.PreviousCallContainsDebuggerStepInCode();
return result;
}