/// <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 + "] 不存在"); }
public ScorpioTypeMethod(Script script, string name, UserdataMethod method, Type type) { m_script = script; m_Type = type; m_Method = method; m_MethodName = name; }
private void InitializeConstructor() { if (!this.m_InitializeConstructor) { this.m_InitializeConstructor = true; this.m_Constructor = new ReflectUserdataMethod(base.m_Script, base.m_Type, base.m_Type.ToString(), base.m_Type.GetTypeInfo().GetConstructors()); } }
private ScorpioMethod GetMethod(object obj, string name, UserdataMethod method) { if (method.IsStatic) { return m_ScorpioMethods[name] = new ScorpioStaticMethod(name, method); } else if (obj == null) { return m_ScorpioMethods[name] = new ScorpioTypeMethod(m_Script, name, method, m_Type); } return new ScorpioObjectMethod(obj, name, method); }
//初始化构造函数 private void InitializeConstructor() { if (m_InitializeConstructor == true) { return; } m_InitializeConstructor = true; m_Constructor = new UserdataMethodReflect(m_Type, m_Type.ToString(), m_Type.GetConstructors(Script.BindingFlag)); }
private void InitializeConstructor() { if (m_InitializeConstructor == true) { return; } m_InitializeConstructor = true; m_Constructor = new ReflectUserdataMethod(m_Script, m_Type, m_Type.ToString(), m_Type.GetConstructors()); }
//初始化构造函数 private void InitializeConstructor() { if (m_InitializeConstructor == true) { return; } m_InitializeConstructor = true; //GetConstructors 去掉 NonPublic 标识, 否则取函数会取出一些错误的函数例如类 System.Diagnostics.Process m_Constructor = new UserdataMethodReflect(m_Type, m_Type.ToString(), m_Type.GetConstructors(BindingFlags.Public | BindingFlags.Static | BindingFlags.Instance | BindingFlags.FlattenHierarchy)); }
private ScorpioMethod GetMethod(object obj, string name, UserdataMethod method) { if (method.IsStatic) { return(m_ScorpioMethods[name] = new ScorpioStaticMethod(name, method)); } else if (obj == null) { return(m_ScorpioMethods[name] = new ScorpioTypeMethod(m_Script, name, method, m_Type)); } return(new ScorpioObjectMethod(obj, name, method)); }
private UserdataMethod GetMethod(string name) { InitializeMethods(); for (int i = 0; i < m_Methods.Length; ++i) { if (m_Methods[i].Name.Equals(name)) { UserdataMethod method = new UserdataMethod(m_Script, m_Type, name, m_Methods); m_Functions.Add(name, method); return(method); } } return(null); }
public override ScriptObject GetValue(object key) { string str = key as string; if (str == null) { throw new ExecutionException(base.m_Script, "Object GetValue只支持String类型"); } if (this.m_Methods.ContainsKey(str)) { return(this.m_Methods[str]); } object obj2 = this.m_UserdataType.GetValue(base.m_Value, str); if (obj2 is UserdataMethod) { UserdataMethod method = (UserdataMethod)obj2; ScriptObject obj3 = base.m_Script.CreateObject(method.IsStatic ? ((object)new ScorpioStaticMethod(str, method)) : ((object)new ScorpioObjectMethod(base.m_Value, str, method))); this.m_Methods.Add(str, obj3); return(obj3); } return(base.m_Script.CreateObject(obj2)); }
public override ScriptObject GetValue(object key) { string name = key as string; if (name == null) { throw new ExecutionException(m_Script, "Object GetValue只支持String类型"); } if (m_Methods.ContainsKey(name)) { return(m_Methods[name]); } var ret = m_UserdataType.GetValue(m_Value, name); if (ret is UserdataMethod) { UserdataMethod method = (UserdataMethod)ret; ScriptObject value = m_Script.CreateObject(method.IsStatic ? (ScorpioMethod) new ScorpioStaticMethod(name, method) : (ScorpioMethod) new ScorpioObjectMethod(m_Value, name, method)); m_Methods.Add(name, value); return(value); } return(m_Script.CreateObject(ret)); }
/// <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 + "] 不存在"); }
private UserdataMethod GetMethod(string name) { InitializeMethods(); for (int i = 0; i < m_Methods.Length; ++i) { if (m_Methods[i].Name.Equals(name)) { UserdataMethod method = new UserdataMethod(m_Script, m_Type, name, m_Methods); m_Functions.Add(name, method); return method; } } return null; }
private void InitializeConstructor() { if (m_InitializeConstructor == true) return; m_InitializeConstructor = true; m_Constructor = new UserdataMethod(m_Script, m_Type, m_Type.ToString(), m_Type.GetConstructors()); }
public ScorpioStaticMethod(string name, UserdataMethod method) { Method = method; MethodName = name; }
public ScorpioObjectMethod(object obj, string name, UserdataMethod method) { m_Object = obj; Method = method; MethodName = name; }