Example #1
0
        public PropertyInfo SearchProperty(string name)
        {
            var propertyArray = MType.GetProperties(/*BindingFlags.DeclaredOnly*/);

            foreach (var property in propertyArray)
            {
                if (ReflectionUtil.IsDeclare(MType, property))
                {
                    MappingCodeAttribute propertyAttr = Attribute.GetCustomAttribute(property, typeof(MappingCodeAttribute)) as MappingCodeAttribute;
                    if (propertyAttr == null)
                    {
                        if (property.Name == name)
                        {
                            //return property;
                            return(ForType.GetProperty(property.Name));
                        }
                    }
                    else
                    {
                        if (propertyAttr.Code == name)
                        {
                            return(ForType.GetProperty(property.Name));
                        }
                    }
                }
            }
            return(null);
        }
Example #2
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);
            }
        }
        /// <summary>
        /// Returns true if any member chosen to be serialized is
        /// A) A property
        /// B) Has only a getter or only a setter
        /// </summary>
        /// <returns></returns>
        private bool AnyNonUniformMembers()
        {
            foreach (var mem in Members)
            {
                var prop = ForType.GetProperty(mem.Key, BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic);

                if (prop == null)
                {
                    continue;
                }

                if ((prop.CanRead && !prop.CanWrite) || (prop.CanWrite && !prop.CanRead))
                {
                    return(true);
                }
            }

            return(false);
        }
Example #4
0
        public ExPropertyInfo SearchExProperty(string name)
        {
            var propertyArray = MType.GetProperties(/*BindingFlags.DeclaredOnly*/);

            foreach (var property in propertyArray)
            {
                if (ReflectionUtil.IsDeclare(MType, property))
                {
                    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);
            }
        }