示例#1
0
        public void RegisterAsync(string path, Func <IRequest, Task <IViewFactory> > handler)
        {
            NoomRouterPath  key   = new NoomRouterPath(path);
            NoomRouterEntry entry = new NoomRouterEntry(key, handler);

            items.Add(key, entry);
        }
示例#2
0
        public async void NavigateTo(string path, object payload)
        {
            NoomRequest     request = new NoomRequest(path, payload);
            NoomRouterEntry entry   = router.Match(request);

            ISegment[]   segments = GetSegments(request);
            IViewFactory factory  = await entry.GetView(request);

            IView view = factory.Create(tools);

            await destination.Render(view, request);

            destination.Render(segments);
        }
示例#3
0
        public void Register(string path, Func <IRequest, IViewFactory> handler)
        {
            Func <IRequest, Task <IViewFactory> > callback = request =>
            {
                TaskCompletionSource <IViewFactory> result = new TaskCompletionSource <IViewFactory>();
                IViewFactory view = handler.Invoke(request);

                result.SetResult(view);
                return(result.Task);
            };

            NoomRouterPath  key   = new NoomRouterPath(path);
            NoomRouterEntry entry = new NoomRouterEntry(key, callback);

            items.Add(key, entry);
        }