当前位置: 首页>>代码示例>>C#>>正文


C# Binder.EnsureNotCustomBinder方法代码示例

本文整理汇总了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;
        }
开发者ID:krytarowski,项目名称:corert,代码行数:10,代码来源:RuntimeSyntheticConstructorInfo.cs

示例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);
        }
开发者ID:nattress,项目名称:corert,代码行数:37,代码来源:RuntimeConstructorInfo.cs

示例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);
        }
开发者ID:nattress,项目名称:corert,代码行数:12,代码来源:RuntimeFieldInfo.cs

示例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);
        }
开发者ID:nattress,项目名称:corert,代码行数:31,代码来源:RuntimePropertyInfo.cs

示例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);
        }
开发者ID:nattress,项目名称:corert,代码行数:19,代码来源:RuntimePropertyInfo.cs

示例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;
        }
开发者ID:krytarowski,项目名称:corert,代码行数:19,代码来源:RuntimePlainConstructorInfo.cs

示例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);
        }
开发者ID:krytarowski,项目名称:corert,代码行数:32,代码来源:RuntimePropertyInfo.cs

示例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);
        }
开发者ID:krytarowski,项目名称:corert,代码行数:20,代码来源:RuntimePropertyInfo.cs

示例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;
        }
开发者ID:nattress,项目名称:corert,代码行数:15,代码来源:RuntimeMethodInfo.cs


注:本文中的System.Reflection.Binder.EnsureNotCustomBinder方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。