For each type we print, we hold the reflected and the readable version of the fields
        /// <summary>
        ///   We ignore all properties as they, in the end, will only point to some computed state or other fields.
        ///   Hence they do not provide information about the actual state of the object.
        /// </summary>
        public List<SanitizedFieldInfo> GetFields(Type type)
        {
            Func<object, object> valueProvider = (o) => methodInfos[type].Invoke(o, new object[0]);
            var syntesizedField = new SanitizedFieldInfo(null, "ToString()", valueProvider);

            return new List<SanitizedFieldInfo>() { syntesizedField };
        }
        /// <summary>
        ///   We ignore all properties as they, in the end, will only point to some computed state or other fields.
        ///   Hence they do not provide information about the actual state of the object.
        /// </summary>
        public List <SanitizedFieldInfo> GetFields(Type type)
        {
            Func <object, object> valueProvider = (o) => methodInfos[type].Invoke(o, new object[0]);
            var syntesizedField = new SanitizedFieldInfo(null, "ToString()", valueProvider);

            return(new List <SanitizedFieldInfo>()
            {
                syntesizedField
            });
        }
 bool IsPublic(SanitizedFieldInfo field)
 {
     switch (field.FieldInfo.MemberType)
     {
         case MemberTypes.Field:
             if ((field.FieldInfo as FieldInfo).IsPublic) return true;
             break;
         case MemberTypes.Property:
             var propertyInfo = (PropertyInfo)field.FieldInfo;
             if (propertyInfo.GetGetMethod(false) != null) return true;
             break;
         default:
             throw new ArgumentOutOfRangeException();
     }
     return false;
 }
Example #4
0
        bool IsPublic(SanitizedFieldInfo field)
        {
            switch (field.FieldInfo.MemberType)
            {
            case MemberTypes.Field:
                if ((field.FieldInfo as FieldInfo).IsPublic)
                {
                    return(true);
                }
                break;

            case MemberTypes.Property:
                var propertyInfo = (PropertyInfo)field.FieldInfo;
                if (propertyInfo.GetGetMethod(false) != null)
                {
                    return(true);
                }
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
            return(false);
        }