/// <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 };
        }
Exemplo n.º 2
0
        /// <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;
 }
Exemplo n.º 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);
        }