Пример #1
0
        public TKTProcDesc SearchProc(TKTProcDesc procDesc)
        {
            var methodArray = MType.GetMethods( );

            foreach (var method in methodArray)
            {
                CodeAttribute procAttr = Attribute.GetCustomAttribute(method, typeof(CodeAttribute)) as CodeAttribute;
                if (procAttr == null)
                {
                    ExMethodInfo exMethod     = GclUtil.CreatExMethodInfo(method, this.ForType);
                    TKTProcDesc  typeProcDesc = ProcDescHelper.CreateProcDesc(exMethod);
                    if (typeProcDesc.Eq(procDesc))
                    {
                        return(typeProcDesc);
                    }
                }
                else
                {
                    ProcDescCodeParser parser = new ProcDescCodeParser();
                    parser.InitType(ForType, method);
                    TKTProcDesc typeProcDesc = parser.Parser(WordDict, procAttr.Code);
                    if (typeProcDesc.Eq(procDesc))
                    {
                        ExMethodInfo exMethod = GclUtil.CreatExMethodInfo(method, this.ForType);
                        typeProcDesc.ExMethod = exMethod;
                        return(typeProcDesc);
                    }
                }
            }
            if (ParentMapping != null)
            {
                return(ParentMapping.SearchProc(procDesc));
            }
            return(null);
        }
Пример #2
0
 public static MethodInfo SearchMethod(Type type, TKTProcDesc procDesc)
 {
     foreach (var method in type.GetMethods())
     {
         ExMethodInfo exMethod   = new ExMethodInfo(method, method.DeclaringType == type);
         TKTProcDesc  methodDesc = CreateProcDesc(exMethod);
         if (methodDesc.Eq(procDesc))
         {
             return(method);
         }
     }
     return(null);
 }
Пример #3
0
        public TKTProcDesc SearchProc(TKTProcDesc procDesc)
        {
            var methodArray = MType.GetMethods(/*BindingFlags.DeclaredOnly*/);

            foreach (var method in methodArray)
            {
                if (ReflectionUtil.IsDeclare(MType, method))
                {
                    TKTProcDesc typeProcDesc = ProcDescHelper.CreateProcDesc(method);
                    if (typeProcDesc.Eq(procDesc))
                    {
                        return(typeProcDesc);
                    }
                }
            }
            return(null);
        }
Пример #4
0
        public override TKTProcDesc SearchProc(TKTProcDesc procDesc)
        {
            var methodArray = this.SharpType.GetMethods( );

            foreach (var method in methodArray)
            {
                if (!ReflectionUtil.IsDeclare(SharpType, method))
                {
                    continue;
                }
                /* 编译器生成的类肯定有标注 */
                ZCodeAttribute procAttr = AttributeUtil.GetAttribute <ZCodeAttribute>(method);// Attribute.GetCustomAttribute(method, typeof(ZCodeAttribute)) as ZCodeAttribute;
                //if (procAttr == null)
                //{
                //    ExMethodInfo exMethod = ZTypeHelper.CreatExMethodInfo(method, this.SharpType);
                //    TKTProcDesc typeProcDesc = ProcDescHelper.CreateProcDesc(exMethod);
                //    if (typeProcDesc.Eq(procDesc))
                //    {
                //        return typeProcDesc;
                //    }
                //}
                //else
                //{
                ProcDescCodeParser parser = new ProcDescCodeParser();
                parser.InitType(SharpType, method);
                TKTProcDesc typeProcDesc = parser.Parser(procAttr.Code);
                if (typeProcDesc.Eq(procDesc))
                {
                    ExMethodInfo exMethod = ZTypeUtil.CreatExMethodInfo(method, this.SharpType);
                    typeProcDesc.ExMethod = exMethod;
                    return(typeProcDesc);
                }
                //}
            }
            if (ParentMapping != null)
            {
                return(ParentMapping.SearchProc(procDesc));
            }
            return(null);
        }
Пример #5
0
        public TKTProcDesc SearchProc(TKTProcDesc procDesc)
        {
            var methodArray = MType.GetMethods(/*BindingFlags.DeclaredOnly*/);

            foreach (var method in methodArray)
            {
                if (ReflectionUtil.IsDeclare(MType, method))
                {
                    MappingCodeAttribute procAttr = Attribute.GetCustomAttribute(method, typeof(MappingCodeAttribute)) as MappingCodeAttribute;
                    if (procAttr == null)
                    {
                        TKTProcDesc typeProcDesc = ProcDescHelper.CreateProcDesc(method);
                        if (typeProcDesc.Eq(procDesc))
                        {
                            return(typeProcDesc);
                        }
                    }
                    else
                    {
                        ProcDescCodeParser parser     = new ProcDescCodeParser();
                        ParameterInfo[]    paramArray = method.GetParameters();
                        foreach (var param in paramArray)
                        {
                            parser.AddType(param.ParameterType);
                        }
                        TKTProcDesc typeProcDesc = parser.Parser(WordDict, procAttr.Code);
                        if (typeProcDesc.Eq(procDesc))
                        {
                            typeProcDesc.Method = method;
                            return(typeProcDesc);
                        }
                    }
                }
            }
            return(null);
        }
Пример #6
0
        public TKTProcDesc SearchProc(TKTProcDesc procDesc)
        {
            var methodArray = MType.GetMethods();

            foreach (var method in methodArray)
            {
                if (ReflectionUtil.IsDeclare(MType, method))
                {
                    //ZCodeAttribute procAttr = Attribute.GetCustomAttribute(method, typeof(ZCodeAttribute)) as ZCodeAttribute;
                    Attribute[] attrs = Attribute.GetCustomAttributes(method, typeof(ZCodeAttribute));
                    if (attrs.Length == 0) // if (procAttr == null)
                    {
                        ExMethodInfo exMethod     = GclUtil.CreatExMethodInfo(method, this.ForType);
                        TKTProcDesc  typeProcDesc = ProcDescHelper.CreateProcDesc(exMethod);
                        if (typeProcDesc.Eq(procDesc))
                        {
                            MethodInfo rmethod = method;
                            if (rmethod.IsAbstract)
                            {
                                rmethod = searchMethodByMethod(method);
                            }
                            if (rmethod == null)
                            {
                                return(null);
                            }
                            else
                            {
                                TKTProcDesc rdesc = ProcDescHelper.CreateProcDesc(exMethod);
                                return(rdesc);
                            }
                        }
                    }
                    else
                    {
                        ParameterInfo[] paramArray = method.GetParameters();

                        parser.InitType(ForType, method);
                        foreach (Attribute attr in attrs)
                        {
                            ZCodeAttribute zCodeAttribute = attr as ZCodeAttribute;
                            TKTProcDesc    typeProcDesc   = parser.Parser(WordDict, zCodeAttribute.Code);
                            if (method.IsStatic && !method.IsAbstract && typeProcDesc.HasSubject() &&
                                typeProcDesc.GetSubjectArg().ArgType == this.ForType)
                            {
                                typeProcDesc = typeProcDesc.CreateTail();
                            }
                            if (typeProcDesc.Eq(procDesc))
                            {
                                MethodInfo rmethod = method;
                                if (rmethod.IsAbstract)
                                {
                                    rmethod = searchMethodByMethod(method);
                                }
                                if (rmethod == null)
                                {
                                    return(null);
                                }
                                else
                                {
                                    ExMethodInfo exMethod = GclUtil.CreatExMethodInfo(rmethod, this.ForType);
                                    typeProcDesc.ExMethod = exMethod;
                                    return(typeProcDesc);
                                }
                            }
                        }
                    }
                }
            }
            if (isRootMapping())
            {
                return(null);
            }
            else
            {
                return(ParentMapping.SearchProc(procDesc));
            }
        }
Пример #7
0
        public TKTProcDesc SearchProc(TKTProcDesc procDesc)
        {
            var methodArray = MType.GetMethods();

            foreach (var method in methodArray)
            {
                if (ReflectionUtil.IsDeclare(MType, method))
                {
                    CodeAttribute procAttr = Attribute.GetCustomAttribute(method, typeof(CodeAttribute)) as CodeAttribute;
                    if (procAttr == null)
                    {
                        ExMethodInfo exMethod     = GclUtil.CreatExMethodInfo(method, this.ForType);
                        TKTProcDesc  typeProcDesc = ProcDescHelper.CreateProcDesc(exMethod);
                        if (typeProcDesc.Eq(procDesc))
                        {
                            MethodInfo rmethod = method;
                            if (rmethod.IsAbstract)
                            {
                                rmethod = searchMethodByMethod(method);
                            }
                            if (rmethod == null)
                            {
                                throw new RTException("方法与被翻译类型的方法不一致");
                            }
                            else
                            {
                                TKTProcDesc rdesc = ProcDescHelper.CreateProcDesc(exMethod);
                                return(rdesc);
                            }
                        }
                    }
                    else
                    {
                        ParameterInfo[] paramArray = method.GetParameters();

                        parser.InitType(ForType, method);
                        TKTProcDesc typeProcDesc = parser.Parser(WordDict, procAttr.Code);
                        if (method.IsStatic && !method.IsAbstract && typeProcDesc.HasSubject() && typeProcDesc.GetSubjectArg().ArgType == this.ForType)
                        {
                            typeProcDesc = typeProcDesc.CreateTail();
                        }
                        if (typeProcDesc.Eq(procDesc))
                        {
                            MethodInfo rmethod = method;
                            if (rmethod.IsAbstract)
                            {
                                rmethod = searchMethodByMethod(method);
                            }
                            if (rmethod == null)
                            {
                                throw new RTException("过程描述标注错误");
                            }
                            else
                            {
                                ExMethodInfo exMethod = GclUtil.CreatExMethodInfo(rmethod, this.ForType);
                                typeProcDesc.ExMethod = exMethod;
                                return(typeProcDesc);
                            }
                        }
                    }
                }
            }
            if (isRootMapping())
            {
                return(null);
            }
            else
            {
                return(ParentMapping.SearchProc(procDesc));
            }
        }
Пример #8
0
        public override TKTProcDesc SearchProc(TKTProcDesc procDesc)
        {
            var methodArray = this.SharpType.GetMethods();

            foreach (var method in methodArray)
            {
                if (!ReflectionUtil.IsDeclare(SharpType, method))
                {
                    continue;
                }
                /* 映射类可能有多个同义的方法对应同一个实际方法 */
                ZCodeAttribute[] attrs = AttributeUtil.GetAttributes <ZCodeAttribute>(method);
                /* 编译器生成的类可能没有标注,没有标注的方法必定在ZMappingType上 */
                if (attrs.Length == 0)
                {
                    ExMethodInfo exMethod     = ZTypeUtil.CreatExMethodInfo(method, this.SharpType);
                    TKTProcDesc  typeProcDesc = ProcDescHelper.CreateProcDesc(exMethod);
                    if (typeProcDesc.Eq(procDesc))
                    {
                        TKTProcDesc rdesc = ProcDescHelper.CreateProcDesc(exMethod);
                        return(rdesc);
                    }
                }
                else if (attrs.Length > 0)
                {
                    ParameterInfo[] paramArray = method.GetParameters();
                    parser.InitType(SharpType, method);
                    foreach (ZCodeAttribute attr in attrs)
                    {
                        ZCodeAttribute zCodeAttribute = attr as ZCodeAttribute;
                        TKTProcDesc    typeProcDesc   = parser.Parser(zCodeAttribute.Code);
                        if (method.IsStatic && !method.IsAbstract && typeProcDesc.HasSubject() &&
                            typeProcDesc.GetSubjectArg().ArgType == this.SharpType)
                        {
                            typeProcDesc = typeProcDesc.CreateTail();
                        }
                        if (typeProcDesc.Eq(procDesc))
                        {
                            ExMethodInfo exMethod = null;// getExMethod(method);
                            /* 非 Abstract 的方法肯定从被映射的类中搜索 */
                            if (method.IsAbstract)
                            {
                                var method2 = searchMethodFromSharp(method);
                                exMethod = ZTypeUtil.CreatExMethodInfo(method2, this.SharpType);
                                //return exMethod;
                            }
                            else
                            {
                                exMethod = ZTypeUtil.CreatExMethodInfo(method, this.ZMappingType);
                                //return exMethod;
                            }
                            typeProcDesc.ExMethod = exMethod;
                            return(typeProcDesc);
                        }
                    }
                }
            }
            if (ParentMapping != null && !isRoot())
            {
                var epi = ParentMapping.SearchProc(procDesc);
                if (epi != null)
                {
                    //epi.IsSelf = false;
                    return(epi);
                }
            }
            return(null);
        }