예제 #1
0
        public IPredicateRoutes <TResult> Subset <TResult>(Route route,
                                                           Expression <Func <TClass, IEnumerable <TResult> > > accessor,
                                                           Action <PredicateRouteOptions> options = null)
        {
            if (Routes.ContainsKey(route))
            {
                throw new ArgumentException($"{route} route already declared");
            }
            var memberAccessExpression = accessor?.Body as MemberExpression;

            if (memberAccessExpression == null)
            {
                throw new ArgumentException("Member access expression expected as body for accessor");
            }

            var optionInstance = new PredicateRouteOptions();

            options?.Invoke(optionInstance);

            var result = new PredicateRoutes <TResult>();

            var routeSubset = new PredicateRouteSubset(route,
                                                       typeof(TResult),
                                                       optionInstance,
                                                       memberAccessExpression,
                                                       result);

            Routes.Add(route, routeSubset);

            return(result);
        }
예제 #2
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="T:System.Object" /> class.
 /// </summary>
 public PredicateRouteSubset(Route route,
                             Type type,
                             PredicateRouteOptions options,
                             MemberExpression accessor,
                             IPredicateRoutesProvider routes)
     : base(route, type, options, accessor)
 {
     Routes = routes;
 }
예제 #3
0
 /// <summary>
 ///     Initializes a new instance of the <see cref="T:System.Object" /> class.
 /// </summary>
 public PredicateRoute(Route route, Type type, PredicateRouteOptions options, MemberExpression accessor)
 {
     if (route == null)
     {
         throw new ArgumentNullException(nameof(route));
     }
     if (type == null)
     {
         throw new ArgumentNullException(nameof(type));
     }
     if (options == null)
     {
         throw new ArgumentNullException(nameof(options));
     }
     if (accessor == null)
     {
         throw new ArgumentNullException(nameof(accessor));
     }
     Options  = options;
     Accessor = accessor;
     Route    = route;
     Type     = type;
 }