public FilterDefiner(List <Type> types, List <Func <Type, bool> > filterActions) : base(types)
        {
            this.types         = types;
            this.filterActions = filterActions;

            filterActions.Add(type => AndFilter(type));
            filterActions.Add(type => type.GetMethods().Any(method => MethodFilters.ApplyTo(method)));
        }
        /// <summary>
        ///     Initializes a new instance of the <see cref="FilterDefiner" /> class.
        /// </summary>
        /// <param name="types">The types.</param>
        /// <param name="filterActions">The filter actions.</param>
        public FilterDefiner([NotNull] List <Type> types, [NotNull] List <Func <Type, bool> > filterActions)
            : base(types)
        {
            _types         = types;
            _filterActions = filterActions;

            filterActions.Add(type => AndFilter(type));
            filterActions.Add(type => type.GetMethods().Any(method => MethodFilters.ApplyTo(method)));
        }
Esempio n. 3
0
        private bool IsUserFiltered(string fullName, string name)
        {
            if (TypeFilters.Any())
            {
                var classFullName = fullName;
                var matched       = TypeFilters.Contains(classFullName);
                if (!matched)
                {
                    return(true);
                }
            }

            if (MethodFilters.Any())
            {
                var methodFullName = $"{fullName}.{name}";
                var matched        = MethodFilters.Contains(methodFullName);
                if (!matched)
                {
                    return(true);
                }
            }

            if (PropertyFilter.Any())
            {
                var propertySetterFullName = $"{fullName}.{name}";
                var propertyGetterFullName = $"{fullName}.{name}";
                var matched = PropertyFilter.Contains(propertySetterFullName) ||
                              MethodFilters.Contains(propertyGetterFullName);
                if (!matched)
                {
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 4
0
 public void AddMethodFilter(string methodFilter)
 {
     MethodFilters.Add(methodFilter);
 }
Esempio n. 5
0
 private void AddFilter <T, TResult>(Expression <Func <T, TResult> > targetMethod, Func <TResult, TResult> filter)
 {
     MethodFilters.Add(new MethodFilter {
         TargetMethod = targetMethod, Filter = filter
     });
 }