Ejemplo n.º 1
0
    void OnlyAddClass(Type type)
    {
        List<string> _typeDic = new List<string>();
        string classFullName = WrapReflectionTools.GetTrueName(type);
        if(!WrapTextTools.IsSupported(classFullName))
            return;
        if(_classBlackList.Contains(classFullName))
            return;

        string assemblyName = WrapReflectionTools.GetWrapFolderName(type);
        string classname = WrapReflectionTools.GetWrapFileName(type);

        string manifest = "";//一个记事本,用来保存哪些内容做了Wrap

        //变量或属性
        List<Property> savePropertys = WrapReflectionTools.GetPropertys(type, ref manifest, _memberBlackList);
        string[] propertyPartStr = WrapTextTools.Propertys2PartStr(classFullName, savePropertys);

        //构造函数
        List<Method> constructMethods = WrapReflectionTools.GetConstructor(type, ref manifest);
        string wrapNew = WrapTextTools.Constructor2PartStr(classFullName, constructMethods);
        WrapTextTools.CallTypes2TypeStr(classFullName, constructMethods, _typeDic);

        //静态方法(最后的参数是忽略属性,因为属性也是一种方法)
        List<Method> staticMethods = WrapReflectionTools.GetStaticMethods(type, ref manifest, savePropertys, _memberBlackList);
        string wrapSCall = WrapTextTools.SCall2PartStr(classFullName, staticMethods);
        WrapTextTools.CallTypes2TypeStr(classFullName, staticMethods, _typeDic);

        //成员方法
        List<Method> memberMethods = WrapReflectionTools.GetInstanceMethods(type, ref manifest, savePropertys, _memberBlackList);
        string wrapMCall = WrapTextTools.MCall2PartStr(classFullName, memberMethods);
        WrapTextTools.CallTypes2TypeStr(classFullName, memberMethods, _typeDic);

        //索引
        List<Method> indexMethods = WrapReflectionTools.GetIndex(type, ref manifest);
        string[] wrapIndex = WrapTextTools.Index2PartStr(classFullName, indexMethods);

        //运算符(数学运算和逻辑运算)
        List<Method> opMethods = WrapReflectionTools.GetOp(type, ref manifest);
        string[] wrapOp = WrapTextTools.Op2PartStr(opMethods);

        UpdateWrapPart(assemblyName, classname, manifest, _typeDic, propertyPartStr,
            wrapNew, wrapSCall, wrapMCall, wrapIndex, wrapOp);
    }