Esempio n. 1
0
        public TktGcl(Type mtype, CnEnDict wordDict)
        {
            MType     = mtype;
            WordDict  = wordDict;
            classAttr = getTKTAttr(MType);

            if (classAttr.ParentMappingType != null)
            {
                ParentMapping = GclUtil.Load(classAttr.ParentMappingType, wordDict);
            }
            else
            {
                if (MType.BaseType != null)
                {
                    ZClassAttribute attr = getTKTAttr(MType.BaseType);
                    if (attr != null)
                    {
                        ParentMapping = GclUtil.Load(MType.BaseType, wordDict);
                    }
                }
            }
            if (ParentMapping == null)
            {
                ParentMapping = GclUtil.Load(typeof(事物), wordDict);
            }
        }
Esempio n. 2
0
        public ExFieldInfo SearchExField(string name)
        {
            var fieldArray = MType.GetFields();

            foreach (FieldInfo field in fieldArray)
            {
                if (ReflectionUtil.IsDeclare(MType, field))
                {
                    CodeAttribute propertyAttr = Attribute.GetCustomAttribute(field, typeof(CodeAttribute)) as CodeAttribute;
                    if (propertyAttr == null)
                    {
                        if (field.Name == name)
                        {
                            return(GclUtil.CreatExFieldInfo(field, ForType));
                            //return field;
                        }
                    }
                    else
                    {
                        if (propertyAttr.Code == name)
                        {
                            return(GclUtil.CreatExFieldInfo(field, ForType));
                            //return field;
                        }
                    }
                }
            }
            if (ParentMapping != null)
            {
                return(ParentMapping.SearchExField(name));
            }
            return(null);
        }
Esempio n. 3
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);
        }
Esempio n. 4
0
        public ExPropertyInfo SearchExProperty(string name)
        {
            var propertyArray = MType.GetProperties(/*BindingFlags.DeclaredOnly*/);

            foreach (var property in propertyArray)
            {
                if (ReflectionUtil.IsDeclare(MType, property))
                {
                    CodeAttribute propertyAttr = Attribute.GetCustomAttribute(property, typeof(CodeAttribute)) as CodeAttribute;
                    if (propertyAttr == null)
                    {
                        if (property.Name == name)
                        {
                            return(GclUtil.CreatExPropertyInfo(property, ForType));
                            //return property;
                        }
                    }
                    else
                    {
                        if (propertyAttr.Code == name)
                        {
                            return(GclUtil.CreatExPropertyInfo(property, ForType));
                            //return property;
                        }
                    }
                }
            }
            if (ParentMapping != null)
            {
                return(ParentMapping.SearchExProperty(name));
            }
            return(null);
        }
Esempio n. 5
0
 public ExFieldInfo SearchExField(string name)
 {
     if (this.ForType.IsEnum)
     {
         var fieldArray = this.ForType.GetFields(BindingFlags.Static | BindingFlags.Public);
         foreach (FieldInfo field in fieldArray)
         {
             ZCodeAttribute propertyAttr = Attribute.GetCustomAttribute(field, typeof(ZCodeAttribute)) as ZCodeAttribute;
             if (propertyAttr == null)
             {
                 if (field.Name == name)
                 {
                     return(GclUtil.CreatExFieldInfo(ForType.GetField(field.Name), ForType));
                     //return ForType.GetField(field.Name);
                 }
             }
             else
             {
                 if (propertyAttr.Code == name)
                 {
                     return(GclUtil.CreatExFieldInfo(ForType.GetField(field.Name), ForType));
                     //return ForType.GetField(field.Name);
                 }
             }
         }
         return(null);
     }
     else
     {
         var fieldArray = MType.GetFields();
         foreach (FieldInfo field in fieldArray)
         {
             if (ReflectionUtil.IsDeclare(MType, field))
             {
                 ZCodeAttribute propertyAttr = Attribute.GetCustomAttribute(field, typeof(ZCodeAttribute)) as ZCodeAttribute;
                 if (propertyAttr == null)
                 {
                     if (field.Name == name)
                     {
                         return(GclUtil.CreatExFieldInfo(ForType.GetField(field.Name), ForType));
                         //return ForType.GetField(field.Name);
                     }
                 }
                 else
                 {
                     if (propertyAttr.Code == name)
                     {
                         return(GclUtil.CreatExFieldInfo(ForType.GetField(field.Name), ForType));
                         //return ForType.GetField(field.Name);
                     }
                 }
             }
         }
         return(null);
     }
 }
Esempio n. 6
0
        public ExPropertyInfo SearchExProperty(string name)
        {
            var propertyArray = MType.GetProperties(/*BindingFlags.DeclaredOnly*/);

            foreach (PropertyInfo property in propertyArray)
            {
                if (ReflectionUtil.IsDeclare(MType, property))
                {
                    if (isExFieldInfoByAttr(name, property))
                    {
                        return(GclUtil.CreatExPropertyInfo(ForType.GetProperty(property.Name), ForType));
                    }

                    /*ExFieldInfo exFieldInfo = searchExFieldInfoByAttr(name, property);
                     * if (exFieldInfo != null)
                     * {
                     *  return exFieldInfo;
                     * }*/
                    /*ZCodeAttribute propertyAttr = Attribute.GetCustomAttribute(property, typeof(ZCodeAttribute)) as ZCodeAttribute;
                     * if (propertyAttr == null)
                     * {
                     *  if (property.Name == name)
                     *  {
                     *      //return ForType.GetExProperty(property.Name);
                     *      return GclUtil.CreatExPropertyInfo(ForType.GetProperty(property.Name), ForType);
                     *  }
                     * }
                     * else
                     * {
                     *  if (propertyAttr.Code == name)
                     *  {
                     *      //return ForType.GetExProperty(property.Name);
                     *      return GclUtil.CreatExPropertyInfo(ForType.GetProperty(property.Name), ForType);
                     *  }
                     * }*/
                }
            }
            if (isRootMapping())
            {
                return(null);
            }
            else
            {
                ExPropertyInfo property = ParentMapping.SearchExProperty(name);
                return(property);
            }
        }
Esempio n. 7
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));
            }
        }
Esempio n. 8
0
 public TKTConstructorDesc SearchConstructor(TKTConstructorDesc bracket)
 {
     return(GclUtil.SearchConstructor(bracket, this.WordDict, this.ForType));
 }
Esempio n. 9
0
        public ExFieldInfo SearchExField(string name)
        {
            if (this.ForType.IsEnum)
            {
                var fieldArray = this.ForType.GetFields(BindingFlags.Static | BindingFlags.Public);
                foreach (FieldInfo field in fieldArray)
                {
                    if (isExFieldInfoByAttr(name, field))
                    {
                        return(GclUtil.CreatExFieldInfo(ForType.GetField(field.Name), ForType));
                    }

                    /*ExFieldInfo exFieldInfo = searchExFieldInfoByAttr(name, field);
                     * if (exFieldInfo != null)
                     * {
                     *  return exFieldInfo;
                     * }*/
                    /*Attribute[] attrs = Attribute.GetCustomAttributes(field, typeof(ZCodeAttribute));
                     * if (propertyAttr == null)
                     * {
                     *  if (field.Name == name)
                     *  {
                     *      return GclUtil.CreatExFieldInfo(ForType.GetField(field.Name), ForType);
                     *      //return ForType.GetField(field.Name);
                     *  }
                     * }
                     * else
                     * {
                     *  if (propertyAttr.Code == name)
                     *  {
                     *      return GclUtil.CreatExFieldInfo(ForType.GetField(field.Name), ForType);
                     *      //return ForType.GetField(field.Name);
                     *  }
                     * }*/
                }
                return(null);
            }
            else
            {
                var fieldArray = MType.GetFields();
                foreach (FieldInfo field in fieldArray)
                {
                    if (ReflectionUtil.IsDeclare(MType, field))
                    {
                        if (isExFieldInfoByAttr(name, field))
                        {
                            return(GclUtil.CreatExFieldInfo(ForType.GetField(field.Name), ForType));
                        }

                        /*ExFieldInfo exFieldInfo = searchExFieldInfoByAttr(name, field);
                         * if (exFieldInfo != null)
                         * {
                         *  return exFieldInfo;
                         * }*/
                        /*
                         * ZCodeAttribute propertyAttr = Attribute.GetCustomAttribute(field, typeof(ZCodeAttribute)) as ZCodeAttribute;
                         * if (propertyAttr == null)
                         * {
                         *  if (field.Name == name)
                         *  {
                         *      return GclUtil.CreatExFieldInfo(ForType.GetField(field.Name), ForType);
                         *  }
                         * }
                         * else
                         * {
                         *  if (propertyAttr.Code == name)
                         *  {
                         *      return GclUtil.CreatExFieldInfo(ForType.GetField(field.Name), ForType);
                         *  }
                         * }*/
                    }
                }
                return(null);
            }
        }
Esempio n. 10
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));
            }
        }
Esempio n. 11
0
 public TKTConstructorDesc SearchConstructor(TKTConstructorDesc desc)
 {
     return(GclUtil.SearchConstructor(desc, this.WordDict, this.ForType));
 }
Esempio n. 12
0
 public ExPropertyInfo SearchExProperty(string name)
 {
     return(GclUtil.SearchExProperty(name, this.ForType));
 }
Esempio n. 13
0
 public ExFieldInfo SearchExField(string name)
 {
     //return this.ForType.GetField(name);
     return(GclUtil.SearchExField(name, this.ForType));
 }