예제 #1
0
        public void Using_the_factory_dsl_to_create_a_routing_engine()
        {
            RoutingEngine <Context> engine = RoutingEngineFactory.New <Context>(x =>
            {
                // specify the Uri accessor from the context type
                x.Uri(context => context.Uri);

                x.Route("version").To(context => { });

                //x.Route<int, int, int>((year, month, day) => "archive/{year}/{month}/{day}");

                //					x.Route("archive/{year}/{month}/{day}", r =>
                //						{
                //							r.Default("year", DateTime.Now.Year);
                //
                //							r.Constrain("year").To<int>(1970, 2099);
                //							r.Constrain("month").To<int>(1, 12);
                //							r.Constrain("day").To<int>()
                //								.Where(k => k >= 1)
                //								.Where((y,m,d) => k <= )
                //							r.Default("month", DateTime.Now.Month);
                //							r.Default("day", DateTime.Now.Day);
                //
                //						});
            });

            engine.ShouldNotBeNull();

            /*
             * Route reportRoute = new Route("{locale}/{year}", new ReportRouteHandler());
             * reportRoute.Defaults = new RouteValueDictionary { { "locale", "en-US" }, { "year", DateTime.Now.Year.ToString() } };
             * reportRoute.Constraints = new RouteValueDictionary { { "locale", "[a-z]{2}-[a-z]{2}" }, { "year", @"\d{4}" } };
             * reportRoute.DataTokens = new RouteValueDictionary { { "format", "short" } };
             * routes.Add(reportRoute);
             * */
        }