示例#1
0
        void initByAttr(CnEnDict wordDict)
        {
            var tattr = Attribute.GetCustomAttribute(MType, typeof(ZMappingAttribute));

            if (tattr != null)
            {
                attr    = tattr as ZMappingAttribute;
                ForType = attr.ForType;
                if (MType != typeof(事物))
                {
                    if (attr.BaseMappingType != null)
                    {
                        ParentMapping = new MappingGcl(attr.BaseMappingType, wordDict);
                    }
                    else
                    {
                        ParentMapping = new MappingGcl(typeof(事物), wordDict);
                    }
                }
            }
            else
            {
                throw new CompileException("没有找到MappingTypeAttribute");
            }
        }
示例#2
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);
            }
        }
示例#3
0
 public MappingGcl(Type mappingedType, CnEnDict wordDict)
 {
     MType = mappingedType;
     //ForType = GetForType();
     WordDict = wordDict;
     initByAttr(wordDict);
 }
示例#4
0
        public static TKTConstructorDesc SearchConstructor(TKTConstructorDesc desc, CnEnDict WordDict, Type ForType)
        {
            TKTConstructorDesc bracket2 = desc;

            if (WordDict != null && desc.Bracket.IsNameValue)
            {
                List <TKTProcArg> args = new List <TKTProcArg>();
                foreach (var arg in desc.Bracket.ListArgs)
                {
                    string     newArgName = WordDict.Get(arg.ArgName);
                    TKTProcArg newArg     = new TKTProcArg(newArgName, arg.ArgType, arg.ArgType.IsGenericType);
                    args.Add(newArg);
                }
                bracket2 = new TKTConstructorDesc(args);
            }
            ConstructorInfo[] constructorInfoArray = ForType.GetConstructors();
            foreach (ConstructorInfo ci in constructorInfoArray)
            {
                if (ci.IsPublic)
                {
                    TKTConstructorDesc bracketCi = ProcDescHelper.CreateProcBracket(ci);
                    if (bracketCi.Eq(bracket2))
                    {
                        return(bracketCi);
                    }
                }
            }
            return(null);
        }
示例#5
0
        public static IGcl Load(Type type, CnEnDict wordDict)
        {
            MappingTypeAttribute mattr = Attribute.GetCustomAttribute(type, typeof(MappingTypeAttribute)) as MappingTypeAttribute;

            if (mattr != null)
            {
                return(new MappingGcl(type, wordDict));
            }

            TKTClassAttribute tcAttr = Attribute.GetCustomAttribute(type, typeof(TKTClassAttribute)) as TKTClassAttribute;

            if (tcAttr != null)
            {
                return(new TktGcl(type, wordDict));
            }

            return(null);
        }
示例#6
0
 public TKTProcDesc Parser(CnEnDict wordDict, string code)
 {
     this.WordDict = wordDict;
     i             = 0;
     desc          = new TKTProcDesc();
     Code          = code;
     while (i < Code.Length)
     {
         if (ch == '(')
         {
             parseBracket();
         }
         else
         {
             parseText();
         }
     }
     return(desc);
 }
示例#7
0
 public void LoadRefTypes()
 {
     TKTTypes = new List <Type>();
     LibWords = new Dictionary <Assembly, CnEnDict>();
     foreach (Assembly asm in this.Refs)
     {
         foreach (Type type in asm.GetTypes())
         {
             if (type.IsPublic)
             {
                 TKTTypes.Add(type);
                 if (ReflectionUtil.IsExtends(type, typeof(CnEnDict)))
                 {
                     CnEnDict dict = ReflectionUtil.NewInstance(type) as CnEnDict;
                     LibWords.Add(asm, dict);
                 }
             }
         }
     }
 }
示例#8
0
        public static IGcl Load(Type type, CnEnDict wordDict)
        {
            ZMappingAttribute mattr = Attribute.GetCustomAttribute(type, typeof(ZMappingAttribute)) as ZMappingAttribute;

            if (mattr != null)
            {
                return(new MappingGcl(type, wordDict));
            }

            ZClassAttribute tcAttr = Attribute.GetCustomAttribute(type, typeof(ZClassAttribute)) as ZClassAttribute;

            if (tcAttr != null)
            {
                return(new TktGcl(type, wordDict));
            }

            ExternalGcl egcl = new ExternalGcl(type, wordDict);

            return(egcl);
        }
示例#9
0
 public ExternalGcl(Type mtype, CnEnDict wordDict)
 {
     MType    = mtype;
     WordDict = wordDict;
 }
示例#10
0
 public TktGcl(Type mtype, CnEnDict wordDict)
 {
     MType    = mtype;
     WordDict = wordDict;
 }
示例#11
0
 public MappingGcl(Type mappingedType, CnEnDict wordDict)
 {
     MType    = mappingedType;
     ForType  = GetForType();
     WordDict = wordDict;
 }