System.Reflection.MonoField.SetValueInternal C# (CSharp) Method

SetValueInternal() private method

private SetValueInternal ( FieldInfo fi, object obj, object value ) : void
fi FieldInfo
obj object
value object
return void
		private static extern void SetValueInternal (FieldInfo fi, object obj, object value);

Usage Example

Esempio n. 1
0
 public override void SetValue(object obj, object val, BindingFlags invokeAttr, Binder binder, CultureInfo culture)
 {
     if (!this.IsStatic)
     {
         if (obj == null)
         {
             throw new TargetException("Non-static field requires a target");
         }
         if (!this.DeclaringType.IsAssignableFrom(obj.GetType()))
         {
             throw new ArgumentException(string.Format("Field {0} defined on type {1} is not a field on the target object which is of type {2}.", this.Name, this.DeclaringType, obj.GetType()), "obj");
         }
     }
     if (this.IsLiteral)
     {
         throw new FieldAccessException("Cannot set a constant field");
     }
     if (binder == null)
     {
         binder = Binder.DefaultBinder;
     }
     this.CheckGeneric();
     if (val != null)
     {
         object obj2 = binder.ChangeType(val, this.type, culture);
         if (obj2 == null)
         {
             throw new ArgumentException(string.Concat(new object[]
             {
                 "Object type ",
                 val.GetType(),
                 " cannot be converted to target type: ",
                 this.type
             }), "val");
         }
         val = obj2;
     }
     MonoField.SetValueInternal(this, obj, val);
 }