Пример #1
0
 public void SetTargetValue(object value)
 {
     if (Target != null && SetMethod != null)
     {
         SetMethod.Invoke(Target, new object[] { value });
     }
 }
        public object SetValue(ref object value, int fieldIndex, float val)
        {
            var box = (T)value;

            SetValueMethod.Invoke(ref box, fieldIndex, val);
            return(box);
        }
Пример #3
0
        /// <summary>
        /// Calls the set method of the android.os.SystemProperties class
        /// </summary>
        /// <param name="PropertyName">The name of the system property to get the value for</param>
        /// <param name="PropertyValue">The value to set for the system property</param>
        /// <returns>The previous value of the specified property or null if it does not exists</returns>
        public static string SetProp(string PropertyName, string PropertyValue)
        {
            // Invoking a static method, first parameter is null
            var r = SetMethod.Invoke(null,
                                     new Java.Lang.String(PropertyName),
                                     new Java.Lang.String(PropertyValue));

            return(r.ToString());
        }
Пример #4
0
 /// <summary>
 /// Notifies the specified value.
 /// </summary>
 /// <param name="value">The value.</param>
 public void Notify(object value)
 {
     if (PropertyOwner != null && SetMethod != null)
     {
         var parameters = new object[1];
         parameters[0] = value;
         SetMethod.Invoke(PropertyOwner, parameters);
     }
     InternalValue = value;
 }
Пример #5
0
        /// <summary>
        /// When overridden in a derived class, sets the property value for a specified object that has the specified binding, index, and culture-specific information.
        /// </summary>
        /// <param name="obj">The object whose property value will be set. </param><param name="value">The new property value. </param><param name="invokeAttr">A bitwise combination of the following enumeration members that specify the invocation attribute: InvokeMethod, CreateInstance, Static, GetField, SetField, GetProperty, or SetProperty. You must specify a suitable invocation attribute. For example, to invoke a static member, set the Static flag. </param><param name="binder">An object that enables the binding, coercion of argument types, invocation of members, and retrieval of <see cref="T:System.Reflection.MemberInfo"/> objects through reflection. If <paramref name="binder"/> is null, the default binder is used. </param><param name="index">Optional index values for indexed properties. This value should be null for non-indexed properties. </param><param name="culture">The culture for which the resource is to be localized. If the resource is not localized for this culture, the <see cref="P:System.Globalization.CultureInfo.Parent"/> property will be called successively in search of a match. If this value is null, the culture-specific information is obtained from the <see cref="P:System.Globalization.CultureInfo.CurrentUICulture"/> property. </param><exception cref="T:System.ArgumentException">The <paramref name="index"/> array does not contain the type of arguments needed.-or- The property's set accessor is not found. </exception><exception cref="T:System.Reflection.TargetException">The object does not match the target type, or a property is an instance property but <paramref name="obj"/> is null. </exception><exception cref="T:System.Reflection.TargetParameterCountException">The number of parameters in <paramref name="index"/> does not match the number of parameters the indexed property takes. </exception><exception cref="T:System.MethodAccessException">There was an illegal attempt to access a private or protected method inside a class. </exception><exception cref="T:System.Reflection.TargetInvocationException">An error occurred while setting the property value. For example, an index value specified for an indexed property is out of range. The <see cref="P:System.Exception.InnerException"/> property indicates the reason for the error.</exception>
        public void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
        {
            var args = new object[1 + (index != null ? index.Length : 0)];

            args[0] = value;
            for (var i = 1; i < args.Length; i++)
            {
                args[i] = index[i - 1];
            }
            SetMethod.Invoke(obj, invokeAttr, binder, args, culture);
        }
Пример #6
0
        /// <summary>
        /// When overridden in a derived class, sets the property value for a specified object that has the specified binding, index, and culture-specific information.
        /// </summary>
        /// <param name="obj">The object whose property value will be set. </param><param name="value">The new property value. </param><param name="invokeAttr">A bitwise combination of the following enumeration members that specify the invocation attribute: InvokeMethod, CreateInstance, Static, GetField, SetField, GetProperty, or SetProperty. You must specify a suitable invocation attribute. For example, to invoke a static member, set the Static flag. </param><param name="binder">An object that enables the binding, coercion of argument types, invocation of members, and retrieval of <see cref="T:System.Reflection.MemberInfo"/> objects through reflection. If <paramref name="binder"/> is null, the default binder is used. </param><param name="index">Optional index values for indexed properties. This value should be null for non-indexed properties. </param><param name="culture">The culture for which the resource is to be localized. If the resource is not localized for this culture, the <see cref="P:System.Globalization.CultureInfo.Parent"/> property will be called successively in search of a match. If this value is null, the culture-specific information is obtained from the <see cref="P:System.Globalization.CultureInfo.CurrentUICulture"/> property. </param><exception cref="T:System.ArgumentException">The <paramref name="index"/> array does not contain the type of arguments needed.-or- The property's set accessor is not found. </exception><exception cref="T:System.Reflection.TargetException">The object does not match the target type, or a property is an instance property but <paramref name="obj"/> is null. </exception><exception cref="T:System.Reflection.TargetParameterCountException">The number of parameters in <paramref name="index"/> does not match the number of parameters the indexed property takes. </exception><exception cref="T:System.MethodAccessException">There was an illegal attempt to access a private or protected method inside a class. </exception><exception cref="T:System.Reflection.TargetInvocationException">An error occurred while setting the property value. For example, an index value specified for an indexed property is out of range. The <see cref="P:System.Exception.InnerException"/> property indicates the reason for the error.</exception>
        public void SetValue(object obj, object value, BindingFlags invokeAttr, Binder binder, object[] index, CultureInfo culture)
        {
            if (SetMethod == null)
            {
                throw new InvalidOperationException("Property '" + DeclaringType.FullName + "." + Name + "' does not have a setter.");
            }
            var args = Jsni.@new(Jsni.reference("Array"), (1 + (index != null ? index.Length : 0)).As <JsObject>()).As <JsArray>();

//                new object[1 + (index != null ? index.Length : 0)];
            args[0] = value.As <JsObject>();
            for (var i = 1; i < args.length; i++)
            {
                args[i] = index[i - 1].As <JsObject>();
            }
            SetMethod.Invoke(obj, invokeAttr, binder, args.As <object[]>(), culture);
        }
        ///// <summary>
        ///// 获取数据库值表达
        ///// </summary>
        ///// <param name="entity"></param>
        ///// <returns></returns>
        //public string GetDbValueStatement(object entity)
        //{
        //    object value = GetMethod.Invoke(entity, null);
        //    return DatabaseEngine.GetDbValueStatement(value);
        //}

        /// <summary>
        /// 赋值
        /// </summary>
        /// <param name="entity"></param>
        /// <param name="value"></param>
        public void SetValue(object entity, object value)
        {
            SetMethod.Invoke(entity, new object[] { value });
        }
Пример #8
0
 public virtual void SetValue(object model, T value)
 {
     SetMethod.Invoke(model, new object[] { value });
 }