예제 #1
0
        /// <summary>
        /// Returns a <see cref="Boolean"/> indicating whether or not the supplied <paramref name="options"/>
        /// contains the <see cref="Type"/> of <paramref name="memberInfo"/> in its
        /// <see cref="ObjectInspectorOptions.ExcludeTypes"/> list.
        /// </summary>
        protected static bool IsExcludedType(ObjectInspectorOptions options, MemberInfo memberInfo)
        {
            Type   propertyType      = memberInfo.ReflectedType;
            string targetTypeLiteral = propertyType.ToString();

            return(options.ExcludeTypes.Contains(targetTypeLiteral));
        }
예제 #2
0
        /// <summary>
        /// Check against the property name to see whether it is on any exclude lists
        /// </summary>
        protected static bool IsExcludedPropertyName(ObjectInspectorOptions options, string targetName)
        {
            string propertyName = targetName;

            // Trap cases where it is like target[0].Legcount (and we are including "legcount"
            int lastPeriodPosition = targetName.LastIndexOf(".");

            if (lastPeriodPosition > 0)
            {
                propertyName = targetName.Substring(lastPeriodPosition + 1);
            }

            // Handle the dataRow case - trim out the row text and get the actual column name
            if (propertyName.StartsWith("Rows"))
            {
                const string columnNamePattern = @"""(\w+)""";
                Regex        regex             = new Regex(columnNamePattern);
                Match        match             = regex.Match(propertyName);

                if (match != null && match.Captures.Count > 0)
                {
                    propertyName = match.Captures[0].Value;
                    propertyName = propertyName.Replace("\"", string.Empty);
                }
            }

            // Do we have any exclusions
            string exclusionTest = options.ExcludeProperties.Find(exclude => string.Compare(targetName, exclude, true) == 0);

            if (!String.IsNullOrEmpty(exclusionTest))
            {
                return(true);
            }

            // Do we only honour explicit includes
            if (!options.EnumerateAllProperties && !options.IncludeProperties.Contains(propertyName))
            {
                return(true);
            }

            // otherwise ok
            return(false);
        }