Ejemplo n.º 1
0
        //获取一个函数,名字相同返回值相同
        private UserdataMethod GetFunction(string name)
        {
            var methods = m_Methods.FindAll((method) => method.Name == name);

            if (methods.Count > 0)
            {
                return(m_Functions[name] = new UserdataMethodReflect(m_Type, name, methods.ToArray()));
            }
            return(null);
        }
        //添加一个扩展函数
        public void AddExtensionMethod(MethodInfo method)
        {
            var name           = method.Name;
            var userdataMethod = GetMethod(name);

            if (userdataMethod == null)
            {
                userdataMethod = (m_Functions[name] = new UserdataMethodReflect(m_Type, name));
            }
            ((UserdataMethodReflect)userdataMethod).AddExtensionMethod(method);
        }