Beispiel #1
0
 public ZLPropertyInfo(ZLClassInfo zClass, PropertyInfo markPropertyInfo, PropertyInfo sharpPropertyInfo)
 {
     ZClass        = zClass;
     MarkProperty  = markPropertyInfo;
     SharpProperty = sharpPropertyInfo;
     Init();
 }
Beispiel #2
0
 public ZLFieldInfo(ZLClassInfo zClass, FieldInfo markPropertyInfo, FieldInfo sharpPropertyInfo)
 {
     ZClass     = zClass;
     MarkField  = markPropertyInfo;
     SharpField = sharpPropertyInfo;
     Init();
 }
Beispiel #3
0
 public ZLMethodInfo(MethodInfo markMethod, MethodInfo sharpMethod, ZLClassInfo zclass)
 {
     ZClass               = zclass;
     MarkMethod           = markMethod;
     SharpMethod          = sharpMethod;
     AccessAttr           = ZClassUtil.GetAccessAttributeEnum(sharpMethod);
     GenericParameterDict = GenericUtil.GetMethodGenericParameters(sharpMethod);
     //Init();
 }
Beispiel #4
0
        public ZLClassInfo MakeGenericType(params ZType[] argZTypes)
        {
            var         args         = argZTypes.Select(U => ZTypeUtil.GetTypeOrBuilder(U)).ToArray();
            Type        newtype      = this.SharpType.MakeGenericType(args);
            ZLClassInfo newclassinfo = new ZLClassInfo(newtype, newtype, IsStatic);

            newclassinfo._GenericTypeDict = new Dictionary <string, Type>();
            Type[] typeArguments = this.SharpType.GetGenericArguments();
            for (int i = 0; i < typeArguments.Length; i++)
            {
                newclassinfo._GenericTypeDict.Add(typeArguments[i].Name, args[i]);
            }
            return(newclassinfo);
        }
Beispiel #5
0
 public void AddZDescType(ZLType descType)
 {
     if (descType is ZLEnumInfo)
     {
         ZLEnumInfo zenum = descType as ZLEnumInfo;
         EnumTypes.Add(zenum);
     }
     else if (descType is ZLClassInfo)
     {
         ZLClassInfo zclass = descType as ZLClassInfo;
         ClassTypes.Add(zclass);
     }
     else
     {
         throw new ZyyRTException();
     }
 }
Beispiel #6
0
        public ZLMethodInfo[] SearchZMethod(ZCMethodDesc zdesc)
        {
            ZLClassInfo temp = this;

            while (temp != null)
            {
                ZLMethodInfo[] zmethods = temp.SearchDeclaredZMethod(zdesc);
                if (zmethods.Length > 0)
                {
                    return(zmethods);
                }
                else
                {
                    temp = temp.BaseZClass;
                }
            }
            return(new ZLMethodInfo[] { });
        }
Beispiel #7
0
        public ZLFieldInfo SearchField(string zname)
        {
            ZLClassInfo temp = this;

            while (temp != null)
            {
                ZLFieldInfo zp = temp.SearchDeclaredZField(zname);
                if (zp != null)
                {
                    return(zp);
                }
                else
                {
                    temp = temp.BaseZClass;
                }
            }
            return(null);
        }
Beispiel #8
0
        public ZLPropertyInfo SearchProperty(string zname)
        {
            ZLClassInfo temp = this;

            while (temp != null)
            {
                ZLPropertyInfo zp = temp.SearchDeclaredZProperty(zname);
                if (zp != null)
                {
                    return(zp);
                }
                else
                {
                    temp = temp.BaseZClass;
                }
            }
            return(null);
        }
Beispiel #9
0
        //public override ZAClassInfo GetZAClass() { return ZClass; }
        //public override ZAParamInfo[] GetZParams() { return ZParams; }
        //public override ZAConstructorDesc GetZDesc() { return ZDesc; }

        #endregion

        public ZLConstructorInfo(ConstructorInfo constructorInfo, ZLClassInfo zclass)
        {
            Constructor = constructorInfo;
            ZClass      = zclass;
            Init();
        }
Beispiel #10
0
        public static ZLConstructorDesc CreateZConstructorDesc(ConstructorInfo ci, ZLConstructorInfo zlc, ZLClassInfo zclass)
        {
            ZLBracketDesc zbracket = new ZLBracketDesc();
            //List<ZArgDefNormalDesc> args = new List<ZArgDefNormalDesc>();
            int index = 0;

            foreach (ParameterInfo param in ci.GetParameters())
            {
                ZLParamInfo arg = new ZLParamInfo(param, zlc, index);// , false);
                zbracket.Add(arg);
                index++;
            }
            ZLConstructorDesc desc = new ZLConstructorDesc(zlc, zbracket);

            return(desc);
        }
Beispiel #11
0
        public static ZLMethodInfo[] GetZMethods(Type markType, Type sharpType, bool isStatic, ZLClassInfo zclass)
        {
            //if (markType.Name == "控制台")
            //{
            //    Console.WriteLine("控制台");
            //}
            List <ZLMethodInfo> list = new List <ZLMethodInfo>();

            MethodInfo[] markMethods = markType.GetMethods();
            foreach (MethodInfo method in markMethods)
            {
                //if (method.Name == "Write")
                //{
                //    Console.WriteLine("Write");
                //}
                if (!ReflectionUtil.IsDeclare(markType, method))
                {
                    continue;
                }
                if (!AttributeUtil.HasAttribute <ZCodeAttribute>(method))
                {
                    continue;
                }
                MethodInfo newMethod = ReflectionUtil.GetMethod(sharpType, method);
                if (newMethod == null)
                {
                    throw new ZyyRTException();
                }
                else
                {
                    if (isStatic == newMethod.IsStatic)
                    {
                        ZLMethodInfo zmethod = new ZLMethodInfo(method, newMethod, zclass);
                        list.Add(zmethod);
                    }
                }
            }
            return(list.ToArray());
        }
Beispiel #12
0
        public static ZLConstructorInfo[] GetZConstructors(Type markType, Type sharpType, bool isStatic, ZLClassInfo zclass)
        {
            List <ZLConstructorInfo> list = new List <ZLConstructorInfo>();

            if (!isStatic)
            {
                ConstructorInfo[] constructors = sharpType.GetConstructors();
                foreach (ConstructorInfo constructor in constructors)
                {
                    ZLConstructorInfo zconstructor = new ZLConstructorInfo(constructor, zclass);
                    list.Add(zconstructor);
                }
            }
            return(list.ToArray());
        }
Beispiel #13
0
        public static ZLPropertyInfo[] GetZPropertys(Type markType, Type sharpType, bool isStatic, ZLClassInfo zclass)
        {
            List <ZLPropertyInfo> list = new List <ZLPropertyInfo>();

            PropertyInfo[] propertyArray = markType.GetProperties();
            foreach (var property in propertyArray)
            {
                if (ReflectionUtil.IsDeclare(markType, property))
                {
                    if (AttributeUtil.HasAttribute <ZCodeAttribute>(property))
                    {
                        PropertyInfo newPropertyInfo = sharpType.GetProperty(property.Name);
                        if (newPropertyInfo == null)
                        {
                            throw new ZyyRTException();
                        }
                        else
                        {
                            if (isStatic == ReflectionUtil.IsStatic(newPropertyInfo))
                            {
                                ZLPropertyInfo zproperty = new ZLPropertyInfo(zclass, property, newPropertyInfo);
                                list.Add(zproperty);
                            }
                        }
                    }
                }
            }
            return(list.ToArray());
        }
Beispiel #14
0
        public static ZLFieldInfo[] GetZFields(Type markType, Type sharpType, bool isStatic, ZLClassInfo zclass)
        {
            List <ZLFieldInfo> list = new List <ZLFieldInfo>();

            FieldInfo[] fields = markType.GetFields();
            foreach (var field in fields)
            {
                if (ReflectionUtil.IsDeclare(markType, field) && AttributeUtil.HasAttribute <ZCodeAttribute>(field))
                {
                    FieldInfo newField = sharpType.GetField(field.Name);
                    if (newField == null)
                    {
                        throw new ZyyRTException();
                    }
                    else
                    {
                        if (isStatic == newField.IsStatic)
                        {
                            ZLFieldInfo zproperty = new ZLFieldInfo(zclass, field, newField);
                            list.Add(zproperty);
                        }
                    }
                }
            }
            return(list.ToArray());
        }
Beispiel #15
0
 public ZLFieldInfo(ZLClassInfo zClass, FieldInfo propertyInfo)
     : this(zClass, propertyInfo, propertyInfo)
 {
 }
Beispiel #16
0
 public ZLPropertyInfo(ZLClassInfo zClass, PropertyInfo propertyInfo)
     : this(zClass, propertyInfo, propertyInfo)
 {
 }