Example #1
0
        public PomonaEngine(IPomonaSession session)
        {
            if (session == null)
                throw new ArgumentNullException(nameof(session));

            this.session = session;
        }
Example #2
0
 public RouteMatchTree(Route route, string path, IPomonaSession session)
 {
     Session = session;
     Root = new UrlSegment(route,
                           path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries)
                               .Select(HttpUtility.UrlDecode)
                               .ToArray(), this);
 }
Example #3
0
 public RouteMatchTree(Route route, string path, IPomonaSession session)
 {
     Session = session;
     Root    = new UrlSegment(route,
                              path.Split(new[] { '/' }, StringSplitOptions.RemoveEmptyEntries)
                              .Select(HttpUtility.UrlDecode)
                              .ToArray(), this);
 }
Example #4
0
        public PomonaEngine(IPomonaSession session)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }

            this.session = session;
        }
 private static IPomonaDataSource GetDataSource(IPomonaSession session)
 {
     var dataSourceType = session.Routes
         .MaybeAs<DataSourceRootRoute>()
         .Select(x => x.DataSource)
         .OrDefault(typeof(IPomonaDataSource));
     var dataSource = (IPomonaDataSource)session.GetInstance(dataSourceType);
     return dataSource;
 }
Example #6
0
        private static IPomonaDataSource GetDataSource(IPomonaSession session)
        {
            var dataSourceType = session.Routes
                                 .MaybeAs <DataSourceRootRoute>()
                                 .Select(x => x.DataSource)
                                 .OrDefault(typeof(IPomonaDataSource));
            var dataSource = (IPomonaDataSource)session.GetInstance(dataSourceType);

            return(dataSource);
        }
Example #7
0
        public RouteMatchTree Resolve(IPomonaSession session, string path)
        {
            if (session == null)
                throw new ArgumentNullException(nameof(session));
            if (path == null)
                throw new ArgumentNullException(nameof(path));

            var match = new RouteMatchTree(this.rootRoute, path, session);

            return match.MatchCount > 0 ? match : null;
        }
Example #8
0
        public RouteMatchTree Resolve(IPomonaSession session, string path)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }
            if (path == null)
            {
                throw new ArgumentNullException(nameof(path));
            }

            var match = new RouteMatchTree(this.rootRoute, path, session);

            return(match.MatchCount > 0 ? match : null);
        }
        internal static IQueryable Query(this IPomonaSession session,
                                         UrlSegment urlSegment)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }
            if (urlSegment == null)
            {
                throw new ArgumentNullException(nameof(urlSegment));
            }

            var request = new PomonaContext(urlSegment, acceptType: typeof(IQueryable), handleException: false);

            return((IQueryable)session.Dispatch(request).Entity);
        }
        internal static object Get(this IPomonaSession session,
                                   UrlSegment urlSegment)
        {
            if (session == null)
            {
                throw new ArgumentNullException(nameof(session));
            }
            if (urlSegment == null)
            {
                throw new ArgumentNullException(nameof(urlSegment));
            }

            var request = new PomonaContext(urlSegment, executeQueryable: true, handleException: false);

            return(session.Dispatch(request).Entity);
        }
        public static PomonaResponse Get(this IPomonaSession session, string url)
        {
            // TODO: Move this to some other class.

            string            urlWithoutQueryPart = url;
            DynamicDictionary query = null;
            var queryStart          = url.IndexOf('?');

            if (queryStart != -1)
            {
                urlWithoutQueryPart = url.Substring(0, queryStart);
                query = url.Substring(queryStart + 1).AsQueryDictionary();
            }

            var relativePath = session.GetInstance <IUriResolver>().ToRelativePath(urlWithoutQueryPart);
            var req          = new PomonaRequest(url, relativePath, query: query);

            return(session.Dispatch(req));
        }