Esempio n. 1
0
        /// <summary>
        /// 通过反射拿函数的参数,带重载的,用%newline%作为分割标记
        /// </summary>
        /// <param name="strFullName">如txt1.Value.Split</param>
        /// <returns></returns>
        public static string findMethodParmsByFullName(string strFullName, string strNs)
        {
            string ret = "";

            for (int i = 0; i < leParm_Cache.Count; i++)
            {
                leParm lp = leParm_Cache[i];
                if (lp.parm_name == strFullName && (lp.parm_ns == strNs || lp.parm_ns == "") && lp.parm_classname != "")
                {
                    //处理cls()之类的东西的构造函数的参数
                    //预留。。。。。
                }

                if (lp.parm_name == strFullName && lp.mi != null && (lp.parm_ns == strNs || lp.parm_ns == "") && lp.parm_type == null)
                {
                    //读取参数列表
                    ParameterInfo[] api = lp.mi.GetParameters();
                    string          p   = "";
                    foreach (ParameterInfo pi in api)
                    {
                        p += pi.ToString() + ",";
                    }
                    if (p != "")
                    {
                        p = p.Substring(0, p.Length - 1);
                    }
                    string com = lp.mi.ReturnType.FullName + " " + lp.parm_name + "(" + p + ")";
                    ret += com + "\r\n<%newline%>";
                }
            }
            return(ret);
        }
Esempio n. 2
0
        /// <summary>
        /// 绑定两个对象
        /// 例如: c.value = b.width.tostring()
        /// b.width.tostring()是已知类型,也就是objold
        /// c.value 是未知类型,绑完就成了已知的了 :)
        /// </summary>
        /// <param name="objnew"></param>
        /// <param name="nsnew"></param>
        /// <param name="objold"></param>
        /// <param name="nsold"></param>
        public static void bindTwoObjects(string objnew, string nsnew, string objold, string nsold)
        {
            //旧的没有,就算了
            if (!hasItem(objold, nsold, true))
            {
                return;
            }

            //新的有了,也算了(其实是应该覆盖的,暂时先懒一下)
            if (hasItem(objnew, nsnew, true))
            {
                return;
            }

            //这段也有bug:  a = func,   a. 的时候,出不来func的重载,因为我找到一个就break了。不过还是那句话,先懒一下
            for (int i = 0; i < leParm_Cache.Count; i++)
            {
                leParm lp = leParm_Cache[i];
                if (lp.parm_name == objold && (lp.parm_ns == nsold || lp.parm_ns == ""))
                {
                    leParm tlp = new leParm(objnew, lp.parm_type, lp.mi, nsnew);
                    tlp.parm_classname = lp.parm_classname;
                    leParm_Cache.Add(tlp);
                    break;
                }
            }
        }
Esempio n. 3
0
        /// <summary>
        /// 获取所有方法,获取的同时缓存获取到的方法。
        /// </summary>
        /// <param name="strFullName">完整名字,例如prop.ID</param>
        /// <returns>方法的字符串列表,如methodname+method   或 funcname+var</returns>
        public static List <string> findMethodInfoByFullName(string strFullName, string strNs)
        {
            List <string> ret = new List <string>();

            //判断中括号情况
            //if(strFullName.Length>2 && strFullName.Substring(strFullName.Length-2) == "[]")
            //{
            //    strFullName = strFullName.Substring(0, strFullName.Length);
            //    haskou = true;
            //}

            for (int i = 0; i < leParm_Cache.Count; i++)
            {
                leParm lp = leParm_Cache[i];
                if (lp.parm_name == strFullName && (lp.parm_ns == strNs || lp.parm_ns == ""))
                {
                    if (lp.parm_type == null)
                    //两种可能:1。函数名。 函数名点了,当然什么也没有。
                    //          2。luanet.import_type()。 这玩意儿返回值的类型未知
                    {
                        if (lp.parm_classname == "" || lp.parm_classname == null)        //第一种可能应验了
                        {
                            return(ret);
                        }
                        if (!asmCache.ContainsKey(lp.parm_classname))                   //可是,找不到类名
                        {
                            return(ret);
                        }
                        Assembly asm = (Assembly)asmCache[lp.parm_classname];
                        lp.parm_type = asm.GetType(lp.parm_classname);
                    }

                    //读取方法列表
                    MethodInfo[] ami = lp.parm_type.GetMethods();
                    foreach (MethodInfo mi in ami)
                    {
                        if (mi.Name.Length > 4)
                        {
                            string head = mi.Name.Substring(0, 4);
                            if (head == "get_" || head == "set_")
                            {
                                continue;
                            }
                        }

                        //中括号的情况
                        MethodInfo tmi = mi.ReturnType.GetMethod("get_Item", new Type[1] {
                            typeof(int)
                        });
                        if (tmi == null)
                        {
                            tmi = mi.ReturnType.GetMethod("Get", new Type[1] {
                                typeof(int)
                            });
                        }
                        if (tmi != null)
                        {
                            if (!hasItem(strFullName + ":" + mi.Name + "()[]", lp.parm_ns))
                            {
                                leParm_Cache.Add(new leParm(strFullName + ":" + mi.Name + "()[]", tmi.ReturnType, lp.parm_ns));
                            }
                        }

                        ret.Add(mi.Name + "+method");
                        if (!hasItem(strFullName + ":" + mi.Name + "()", lp.parm_ns, mi.ToString()))
                        {
                            leParm_Cache.Add(new leParm(strFullName + ":" + mi.Name + "()", mi.ReturnType, mi, lp.parm_ns));
                        }
                        if (!hasItem(strFullName + ":" + mi.Name, lp.parm_ns, mi.ToString()))
                        {
                            leParm_Cache.Add(new leParm(strFullName + ":" + mi.Name, null, mi, lp.parm_ns));
                        }
                    }

                    //读取属性列表
                    PropertyInfo[] api = lp.parm_type.GetProperties();
                    foreach (PropertyInfo pi in api)
                    {
                        //中括号的情况
                        MethodInfo tmi = pi.PropertyType.GetMethod("get_Item", new Type[1] {
                            typeof(int)
                        });
                        if (tmi == null)
                        {
                            tmi = pi.PropertyType.GetMethod("Get", new Type[1] {
                                typeof(int)
                            });
                        }
                        if (tmi != null)
                        {
                            if (!hasItem(strFullName + ":" + pi.Name + "[]", lp.parm_ns))
                            {
                                leParm_Cache.Add(new leParm(strFullName + "." + pi.Name + "[]", tmi.ReturnType, lp.parm_ns));
                            }
                        }

                        ret.Add(pi.Name + "+table");
                        if (!hasItem(strFullName + ":" + pi.Name, lp.parm_ns))
                        {
                            leParm_Cache.Add(new leParm(strFullName + "." + pi.Name, pi.PropertyType, lp.parm_ns));
                        }
                    }

                    //读取类型列表
                    FieldInfo[] afi = lp.parm_type.GetFields();
                    foreach (FieldInfo fi in afi)
                    {
                        //中括号的情况
                        MethodInfo tmi = fi.FieldType.GetMethod("get_Item", new Type[1] {
                            typeof(int)
                        });
                        if (tmi == null)
                        {
                            tmi = fi.FieldType.GetMethod("Get", new Type[1] {
                                typeof(int)
                            });
                        }
                        if (tmi != null)
                        {
                            if (!hasItem(strFullName + ":" + fi.Name + "[]", lp.parm_ns))
                            {
                                leParm_Cache.Add(new leParm(strFullName + "." + fi.Name + "[]", tmi.ReturnType, lp.parm_ns));
                            }
                        }

                        ret.Add(fi.Name + "+var");
                        if (!hasItem(strFullName + ":" + fi.Name, lp.parm_ns))
                        {
                            leParm_Cache.Add(new leParm(strFullName + "." + fi.Name, fi.FieldType, lp.parm_ns));
                        }
                    }
                    break;
                }
            }
            return(ret);
        }
Esempio n. 4
0
        public static void regEvent(QueryEventsArgs e, string funcName, string strInfo, leParm lep1, leParm lep2, leParm lep3, leParm lep4)
        {
            List <leParm> tlist = new List <leParm>();

            tlist.Add(lep1);
            tlist.Add(lep2);
            tlist.Add(lep3);
            tlist.Add(lep4);
            e.leec.m_list.Add(new leEvent(funcName, tlist, strInfo));
        }
Esempio n. 5
0
        /// <summary>
        /// 绑定两个对象
        /// 例如: c.value = b.width.tostring()
        /// b.width.tostring()是已知类型,也就是objold
        /// c.value 是未知类型,绑完就成了已知的了 :)
        /// </summary>
        /// <param name="objnew"></param>
        /// <param name="nsnew"></param>
        /// <param name="objold"></param>
        /// <param name="nsold"></param>
        public static void bindTwoObjects(string objnew,string nsnew, string objold, string nsold)
        {
            //旧的没有,就算了
            if(!hasItem(objold, nsold, true))
            {
                return;
            }

            //新的有了,也算了(其实是应该覆盖的,暂时先懒一下)
            if (hasItem(objnew, nsnew, true))
            {
                return;
            }

            //这段也有bug:  a = func,   a. 的时候,出不来func的重载,因为我找到一个就break了。不过还是那句话,先懒一下 
            for (int i = 0; i < leParm_Cache.Count; i++)
            {
                leParm lp = leParm_Cache[i];
                if (lp.parm_name == objold && (lp.parm_ns == nsold || lp.parm_ns == ""))
                {
                    leParm tlp = new leParm(objnew, lp.parm_type, lp.mi, nsnew);
                    tlp.parm_classname = lp.parm_classname;
                    leParm_Cache.Add(tlp);
                    break;
                }
            }
        }
Esempio n. 6
0
 public static void regEvent(QueryEventsArgs e, string funcName, string strInfo, leParm lep1, leParm lep2, leParm lep3, leParm lep4)
 {
     List<leParm> tlist = new List<leParm>();
     tlist.Add(lep1);
     tlist.Add(lep2);
     tlist.Add(lep3);
     tlist.Add(lep4);
     e.leec.m_list.Add(new leEvent(funcName, tlist, strInfo));
 }