/// <summary> 获得一个类变量 </summary> public override object GetValue_impl(object obj, string name) { if (m_Functions.ContainsKey(name)) { return(m_Functions[name]); } if (m_NestedTypes.ContainsKey(name)) { return(m_NestedTypes[name]); } UserdataVariable variable = GetVariable(name); if (variable != null) { return(variable.GetValue(obj)); } ScriptUserdata nestedType = GetNestedType(name); if (nestedType != null) { return(nestedType); } UserdataMethod func = GetMethod(name); if (func != null) { return(func); } throw new ExecutionException(m_Script, "GetValue Type[" + m_Type.ToString() + "] 变量 [" + name + "] 不存在"); }
/// <summary> 设置一个类变量 </summary> public override void SetValue(object obj, string name, ScriptObject value) { UserdataVariable variable = GetVariable(name); if (variable == null) { throw new ExecutionException(m_Script, "SetValue Type[" + m_Type + "] 变量 [" + name + "] 不存在"); } try { variable.SetValue(obj, Util.ChangeType(m_Script, value, variable.FieldType)); } catch (System.Exception e) { throw new ExecutionException(m_Script, "SetValue 出错 源类型:" + (value == null || value.IsNull ? "null" : value.ObjectValue.GetType().Name) + " 目标类型:" + variable.FieldType.Name + " : " + e.ToString()); } }
public override void SetValue_impl(object obj, string name, ScriptObject value) { UserdataVariable variable = this.GetVariable(name); if (variable == null) { throw new ExecutionException(base.m_Script, string.Concat(new object[] { "SetValue Type[", base.m_Type, "] 变量 [", name, "] 不存在" })); } try { variable.SetValue(obj, Util.ChangeType(base.m_Script, value, variable.FieldType)); } catch (Exception exception) { throw new ExecutionException(base.m_Script, "SetValue 出错 源类型:" + (((value == null) || value.IsNull) ? "null" : value.ObjectValue.GetType().Name) + " 目标类型:" + variable.FieldType.Name + " : " + exception.ToString()); } }
/// <summary> 获得一个类变量 </summary> public override object GetValue(object obj, string name) { if (m_ScorpioMethods.ContainsKey(name)) { return(m_ScorpioMethods[name]); } if (m_Functions.ContainsKey(name)) { return(GetMethod(obj, name, m_Functions[name])); } if (m_NestedTypes.ContainsKey(name)) { return(m_NestedTypes[name]); } UserdataVariable variable = GetVariable(name); if (variable != null) { return(variable.GetValue(obj)); } Type nestedType = m_Type.GetNestedType(name, Script.BindingFlag); if (nestedType != null) { ScriptUserdata ret = m_Script.CreateUserdata(nestedType); m_NestedTypes.Add(name, ret); return(ret); } UserdataMethod func = GetMethod(name); if (func != null) { return(GetMethod(obj, name, func)); } throw new ExecutionException(m_Script, "GetValue Type[" + m_Type.ToString() + "] 变量 [" + name + "] 不存在"); }