Exemple #1
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);
        }
Exemple #2
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);
     }
 }
Exemple #3
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);
            }
        }