Exemplo n.º 1
0
        public sealed override void SetValue(Object obj, Object value, Object[] index)
        {
            if (ReflectionTrace.Enabled)
            {
                ReflectionTrace.PropertyInfo_SetValue(this, obj, value, index);
            }

            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.RuntimeType, setterMethodHandle, Array.Empty <RuntimeType>(), 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);
        }
Exemplo n.º 2
0
        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
            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, binder, invokeAttr, culture);
        }
Exemplo n.º 3
0
        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
            if (invokeAttr != BindingFlags.Default || binder != null || culture != null)
            {
                throw new NotImplementedException();
            }

            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);
        }