Example #1
0
        public static SievePropertyMapper ApplyConfiguration <T>(this SievePropertyMapper mapper) where T : ISieveConfiguration, new()
        {
            var configuration = new T();

            configuration.Configure(mapper);
            return(mapper);
        }
Example #2
0
 public SieveProcessor(IOptions <SieveOptions> options,
                       ISieveCustomFilterMethods customFilterMethods)
 {
     mapper               = MapProperties(mapper);
     _options             = options;
     _customFilterMethods = customFilterMethods;
 }
Example #3
0
 public PropertyFluentApi(SievePropertyMapper sievePropertyMapper, Expression <Func <TEntity, object> > expression)
 {
     _sievePropertyMapper   = sievePropertyMapper;
     (_fullName, _property) = GetPropertyInfo(expression);
     _name      = _fullName;
     _canFilter = false;
     _canSort   = false;
 }
Example #4
0
        public static SievePropertyMapper ApplyConfigurationsFromAssembly(this SievePropertyMapper mapper, Assembly assembly)
        {
            foreach (var type in assembly.GetTypes().Where(t => !t.IsAbstract && !t.IsGenericTypeDefinition))
            {
                // Only accept types that contain a parameterless constructor, are not abstract.
                var noArgConstructor = type.GetConstructor(Type.EmptyTypes);
                if (noArgConstructor is null)
                {
                    continue;
                }

                if (type.GetInterfaces().Any(t => t == typeof(ISieveConfiguration)))
                {
                    var configuration = (ISieveConfiguration)noArgConstructor.Invoke(new object?[] { });
                    configuration.Configure(mapper);
                }
            }

            return(mapper);
        }
Example #5
0
 public SieveProcessor(IOptions <SieveOptions> options)
 {
     mapper   = MapProperties(mapper);
     _options = options;
 }
Example #6
0
 protected virtual SievePropertyMapper MapProperties(SievePropertyMapper mapper)
 {
     return(mapper);
 }