static void handlePros(TextFile tfClass, Type type, GeneratorHelp.ATypeInfo ti, Action <Type> OnNewType)
        {
            Action <PropertyInfo> action = (pro) =>
            {
                bool isI = type.IsInterface;

                OnNewType(pro.PropertyType);
                ParameterInfo[] ps = pro.GetIndexParameters();

                args iargs     = new args();
                bool isIndexer = (ps.Length > 0);
                if (isIndexer)
                {
                    for (int j = 0; j < ps.Length; j++)
                    {
                        iargs.AddFormat("{0} {1}", typefn(ps[j].ParameterType, type.Namespace), ps[j].Name);
                        OnNewType(ps[j].ParameterType);
                    }
                }

                MethodInfo getm = pro.GetGetMethod();
                MethodInfo setm = pro.GetSetMethod();

                bool canGet = getm != null && getm.IsPublic;
                bool canSet = setm != null && setm.IsPublic;

                string getset = "";

                if (!isI)
                {
                    if (canGet)
                    {
                        getset += string.Format("get {{ return default({0}); }}", typefn(pro.PropertyType, type.Namespace));
                    }
                    if (canSet)
                    {
                        getset += " set {}";
                    }
                }
                else
                {
                    if (canGet)
                    {
                        getset += "get;";
                    }
                    if (canSet)
                    {
                        getset += " set;";
                    }
                }

                string vo = string.Empty;
                if (!isI)
                {
                    vo = "public ";

                    if ((getm != null && getm.IsStatic) ||
                        (setm != null && setm.IsStatic))
                    {
                        vo += "static ";
                    }

                    if (!type.IsValueType)
                    {
                        if ((getm != null && getm.IsVirtual) ||
                            (setm != null && setm.IsVirtual))
                        {
                            vo += ((getm != null && getm.GetBaseDefinition() != getm) || (setm != null && setm.GetBaseDefinition() != setm))
                                ? "override " : "virtual ";
                        }
                    }
                }


                if (isIndexer)
                {
                    tfClass.Add("{3}{0} this{1} {{ {2} }}",
                                typefn(pro.PropertyType, type.Namespace), iargs.Format(args.ArgsFormat.Indexer),
                                getset,
                                vo);
                }
                else
                {
                    tfClass.Add("{3}{0} {1} {{ {2} }}",
                                typefn(pro.PropertyType, type.Namespace), pro.Name,
                                getset,
                                vo);
                }
            };

            bool hasNoneIndexer = false;

            for (int i = 0; i < ti.Pros.Count; i++)
            {
                MemberInfoEx infoEx = ti.Pros[i];
                PropertyInfo pro    = infoEx.member as PropertyInfo;
                if (pro.GetIndexParameters().Length == 0)
                {
                    hasNoneIndexer = true;
                    action(pro);
                }
            }

            if (hasNoneIndexer)
            {
                tfClass.AddLine();
            }

            for (int i = 0; i < ti.Pros.Count; i++)
            {
                MemberInfoEx infoEx = ti.Pros[i];
                PropertyInfo pro    = infoEx.member as PropertyInfo;
                if (pro.GetIndexParameters().Length > 0)
                {
                    action(pro);
                }
            }
        }
        static void handleInterfaceProblems(TextFile tfClass, Type cType, Action <Type> OnNewType)
        {
            Type[] interfaces = cType.GetValidInterfaces();
            Action <Type, MethodInfo> actionMethod = (iType, method) =>
            {
                StringBuilder sbDef = new StringBuilder();

                sbDef.Append("extern ");
                if (!(method.IsSpecialName && method.Name == "op_Implicit"))
                {
                    sbDef.Append(typefn(method.ReturnType, cType.Namespace, CsNameOption.CompilableWithT) + " ");
                }

                OnNewType(method.ReturnType);

                sbDef.Append(iType.CsFullName(CsNameOption.CompilableWithT) + ".");                 // 这句是重点
                sbDef.Append(MethodNameString(cType, method));

                if (method.IsGenericMethodDefinition)
                {
                    Type[] argus  = method.GetGenericArguments();
                    args   t_args = new args();
                    foreach (var a in argus)
                    {
                        t_args.Add(a.Name);
                    }

                    sbDef.Append(t_args.Format(args.ArgsFormat.GenericT));
                }

                sbDef.Append("(");
                ParameterInfo[] ps = method.GetParameters();
                {
                    sbDef.Append(Ps2String(cType, ps));
                    sbDef.Append(");");

                    foreach (var p in ps)
                    {
                        OnNewType(p.ParameterType);
                    }
                }

                tfClass.Add(sbDef.ToString());
            };

            Action <Type, PropertyInfo> actionPro = (iType, pro) =>
            {
                OnNewType(pro.PropertyType);
                ParameterInfo[] ps = pro.GetIndexParameters();

                args iargs     = new args();
                bool isIndexer = (ps.Length > 0);
                if (isIndexer)
                {
                    for (int j = 0; j < ps.Length; j++)
                    {
                        iargs.AddFormat("{0} {1}", typefn(ps[j].ParameterType, cType.Namespace), ps[j].Name);
                        OnNewType(ps[j].ParameterType);
                    }
                }

                MethodInfo getm = pro.GetGetMethod();
                MethodInfo setm = pro.GetSetMethod();

                bool canGet = getm != null && getm.IsPublic;
                bool canSet = setm != null && setm.IsPublic;

                string getset = "";
                {
                    if (canGet)
                    {
                        getset += "get;";
                    }
                    if (canSet)
                    {
                        getset += " set;";
                    }
                }

                string vo = string.Empty;

                if (isIndexer)
                {
                    tfClass.Add("extern {4}{0} {1}{2} {{ {3} }}",
                                typefn(pro.PropertyType, cType.Namespace),
                                iType.CsFullName(CsNameOption.CompilableWithT) + ".this", // 这句是重点
                                iargs.Format(args.ArgsFormat.Indexer),
                                getset,
                                vo);
                }
                else
                {
                    tfClass.Add("extern {3}{0} {1} {{ {2} }}",
                                typefn(pro.PropertyType, cType.Namespace),
                                iType.CsFullName(CsNameOption.CompilableWithT) + "." +                     // 这句是重点
                                pro.Name,
                                getset,
                                vo);
                }
            };

            foreach (Type iType in interfaces)
            {
                GeneratorHelp.ATypeInfo ti = GeneratorHelp.CreateTypeInfo(iType);
                for (int i = 0; i < ti.Methods.Count; i++)
                {
                    MemberInfoEx infoEx = ti.Methods[i];
                    MethodInfo   method = infoEx.member as MethodInfo;
                    actionMethod(iType, method);
                }
                for (int i = 0; i < ti.Pros.Count; i++)
                {
                    MemberInfoEx infoEx = ti.Pros[i];
                    PropertyInfo pro    = infoEx.member as PropertyInfo;
                    actionPro(iType, pro);
                }
                // 特殊处理,BridgeProj工程
                if (iType == typeof(ICollection))
                {
                    tfClass.Add("bool System.Collections.ICollection.IsReadOnly { get; }");
                }
            }
        }
        public static void BuildConstructors(TextFile tfInst, Type type, List <MemberInfoEx> constructors, int slot)
        {
            var argActual = new args();
            var argFormal = new args();

            for (int i = 0; i < constructors.Count; i++)
            {
                MemberInfoEx infoEx = constructors[i];
                if (infoEx.Ignored)
                {
                    continue;
                }
                ConstructorInfo con = infoEx.member as ConstructorInfo;

                TextFile        tf = new TextFile();
                ParameterInfo[] ps = con == null ? new ParameterInfo[0] : con.GetParameters();

                argActual.Clear().Add(
                    (int)JSVCall.Oper.CONSTRUCTOR, // OP
                    slot,
                    i,                             // NOTICE
                    "true",                        // IsStatics
                    "this"
                    );

                argFormal.Clear();

                // add T to formal param
                Type[] GAs = null;
                if (type.IsGenericTypeDefinition)
                {
                    GAs = type.GetGenericArguments();
                    for (int j = 0; j < GAs.Length; j++)
                    {
                        //argFormal.Add("t" + j + "");
                        argActual.AddFormat("${0}", GAs[j].Name);
                    }
                }

                //StringBuilder sbFormalParam = new StringBuilder();
                //StringBuilder sbActualParam = new StringBuilder();
                for (int j = 0; j < ps.Length; j++)
                {
                    argFormal.Add("a" + j.ToString());
                    argActual.Add("a" + j.ToString());
                }

                string mName = Ctor_Name(infoEx.GetOverloadIndex());

                // 特殊处理 - MonoBehaviour 不需要构造函数内容
                if (type == typeof(MonoBehaviour))
                {
                    tf.Add("{0}: function ({1}) {{}},", mName, argFormal);
                }
                // 再次特殊处理
                else if (type == typeof(WaitForSeconds))
                {
                    tf.Add("{0}: function ({1}) {{", mName, argFormal)
                    .In()
                    .Add("this.$totalTime = a0;")
                    .Add("this.$elapsedTime = 0;")
                    .Add("this.$finished = false;")
                    .Out().Add("},");
                }
                else
                {
                    TextFile tfFun = tf.Add("{0}: function ({1}) {{", mName, argFormal)
                                     .In();

                    if (type.IsGenericTypeDefinition)
                    {
                        tfFun.Add("var $GAs = Bridge.Reflection.getGenericArguments(Bridge.getType(this));");
                        for (int j = 0; j < GAs.Length; j++)
                        {
                            tfFun.Add("var ${0} = Bridge.Reflection.getTypeFullName($GAs[{1}]);",
                                      GAs[j].Name, j);
                        }
                    }

                    tfFun.Add("CS.Call({0});", argActual)
                    .Out().Add("},");
                }
                tfInst.Add(tf.Ch);
            }
        }