示例#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 static ZType CreateZType(Type type)
        {
            ZClassAttribute zAttr = AttributeUtil.GetAttribute <ZClassAttribute>(type);

            if (zAttr != null)
            {
                if (type.IsEnum)
                {
                    return(new ZEnumGenType(type));
                }
                else
                {
                    return(new ZClassGenType(type));
                }
            }
            else
            {
                ZMappingAttribute mAttr = AttributeUtil.GetAttribute <ZMappingAttribute>(type);
                if (mAttr == null)
                {
                    return(null);
                }
                if (type.IsEnum)
                {
                    return(new ZEnumMappingType(type));
                }
                else
                {
                    return(new ZEnumGenType(type));
                }
            }
            //return null;
        }
示例#3
0
        public ZClassMappingType(Type type)
        {
            this.ZMappingType     = type;
            this.MappingAttribute = AttributeUtil.GetAttribute <ZMappingAttribute>(type);
            this.SharpType        = MappingAttribute.ForType;

            Type       baseType = MappingAttribute.BaseMappingType != null ? MappingAttribute.BaseMappingType : typeof(Z语言系统.事物);
            ZClassType zc       = ZType.CreateZType(baseType) as ZClassType;

            ZClassTypeCache.One.Set(baseType, zc);
            this.ParentMapping = ZClassTypeCache.One.Get(baseType);
        }
示例#4
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);
        }