SetValue() public method

public SetValue ( object obj, object val ) : void
obj object
val object
return void
Ejemplo n.º 1
0
        /// <summary> 设置一个类变量 </summary>
        public void SetValue(object obj, string name, ScriptObject value)
        {
            UserdataField field = GetField(name);

            if (field == null)
            {
                throw new ScriptException("SetValue Type[" + m_Type + "] 变量 [" + name + "] 不存在");
            }
            field.SetValue(obj, Util.ChangeType(value, field.FieldType));
        }
Ejemplo n.º 2
0
        /// <summary> 设置一个类变量 </summary>
        public void SetValue(object obj, string name, ScriptObject value)
        {
            UserdataField field = GetField(name);

            if (field == null)
            {
                throw new ExecutionException(m_Script, "SetValue Type[" + m_Type + "] 变量 [" + name + "] 不存在");
            }
            try {
                field.SetValue(obj, Util.ChangeType(m_Script, value, field.FieldType));
            } catch (System.Exception e) {
                throw new ExecutionException(m_Script, "SetValue 出错 源类型:" + (value == null || value.IsNull ? "null" : value.ObjectValue.GetType().Name) + " 目标类型:" + field.FieldType.Name + " : " + e.ToString());
            }
        }
Ejemplo n.º 3
0
        /// <summary> 设置一个类变量 </summary>
        public void SetValue(object obj, string name, ScriptObject value)
        {
            UserdataField field = GetField(name);

            if (field == null)
            {
                throw new ScriptException("SetValue Type[" + m_Type + "] 变量 [" + name + "] 不存在");
            }
            try {
                field.SetValue(obj, Util.ChangeType(value, field.FieldType));
            } catch (System.Exception) {
                throw new ScriptException("不能从源类型:" + (value == null || value.IsNull ? "null" : value.ObjectValue.GetType().Name) + " 转换成目标类型:" + field.FieldType.Name);
            }
        }