一个类的同名函数
Esempio n. 1
0
        /// <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());
     }
 }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
 //初始化构造函数
 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));
 }
Esempio n. 6
0
 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));
 }
Esempio n. 8
0
 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));
 }
Esempio n. 9
0
 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);
 }
Esempio n. 10
0
        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));
        }
Esempio n. 12
0
        /// <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 + "] 不存在");
        }
Esempio n. 13
0
 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;
 }
Esempio n. 14
0
 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());
 }
Esempio n. 15
0
 public ScorpioStaticMethod(string name, UserdataMethod method)
 {
     Method = method;
     MethodName = name;
 }
Esempio n. 16
0
 public ScorpioObjectMethod(object obj, string name, UserdataMethod method)
 {
     m_Object = obj;
     Method = method;
     MethodName = name;
 }