Esempio n. 1
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 <SanitiedFieldInfo> GetFields(Type type)
        {
            Func <object, object> valueProvider = (o) => methodInfos[type].Invoke(o, new object[0]);
            var syntesizedField = new SanitiedFieldInfo(null, "ToString()", valueProvider);

            return(new List <SanitiedFieldInfo>()
            {
                syntesizedField
            });
        }
        bool IsPublic(SanitiedFieldInfo 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);
        }