Ejemplo n.º 1
0
 /// <summary>
 /// 设置字段值
 /// </summary>
 /// <param name="target">拥有该成员的类实例</param>
 /// <param name="value">字段/属性值</param>
 private void Set(object target, object value)
 {
     if (_set == null)
     {
         _set = FieldInvoker.InitializeSetter(_member);
     }
     value = value ?? TypeUtils.GetNullValue(_member.FieldType);
     _set(target, value);
 }
Ejemplo n.º 2
0
 /// <summary>
 /// 设置属性值
 /// </summary>
 /// <param name="target">拥有该成员的类实例</param>
 /// <param name="value">字段/属性值</param>
 private void Set(object target, object value)
 {
     if (!_member.CanWrite)
     {
         throw new XFrameworkException("{0} is unwritable", base.FullName);
     }
     //value = value ?? TypeUtils.GetNullValue(_member.PropertyType);
     //if (value != null)
     //{
     //    if (value.GetType() != this.DataType) value = Convert.ChangeType(value, this.DataType);
     //}
     _set = _set ?? PropertyInvoker.InitializeSetInvoke(this);
     _set(target, value ?? TypeUtils.GetNullValue(_member.PropertyType));
 }
Ejemplo n.º 3
0
 /// <summary>
 /// 动态访问成员
 /// </summary>
 /// <param name="target">拥有该成员的类实例</param>
 /// <param name="value">字段/属性值</param>
 public override object Invoke(object target, params object[] parameters)
 {
     if (parameters != null && parameters.Length == 0)
     {
         // get
         object obj = Get(target);
         return(obj);
     }
     else
     {
         // set
         Set(target, parameters != null ? parameters[0] : TypeUtils.GetNullValue(base.DataType));
         return(null);
     }
 }