Example #1
0
        public HomeModule(IViewLocationProvider viewLocationProvider)
        {
            this.viewLocationProvider = viewLocationProvider;

            Get["/"] = _ =>
            {
                var popularposts = GetModel();

                dynamic postModel = new ExpandoObject();
                postModel.PopularPosts = popularposts;
                postModel.MetaData     = popularposts;

                return(View["blogindex", postModel]);
            };

            Get["/{viewname}"] = parameters =>
            {
                var popularposts = GetModel();

                dynamic postModel = new ExpandoObject();
                postModel.PopularPosts = popularposts;
                postModel.MetaData     =
                    popularposts.FirstOrDefault(x => x.Slug == parameters.viewname);

                return(View["Posts/" + parameters.viewname, postModel]);
            };
        }
Example #2
0
        public HomeModule(IViewLocationProvider viewLocationProvider)
        {
            this.viewLocationProvider = viewLocationProvider;

            Get["/"] = _ =>
            {
                var popularposts = GetModel();

                dynamic postModel = new ExpandoObject();
                postModel.PopularPosts = popularposts;
                postModel.MetaData = popularposts;

                return View["blogindex", postModel];
            };

            Get["/{viewname}"] = parameters =>
            {
                var popularposts = GetModel();

                dynamic postModel = new ExpandoObject();
                postModel.PopularPosts = popularposts;
                postModel.MetaData =
                popularposts.FirstOrDefault(x => x.Slug == parameters.viewname);

                return View["Posts/" + parameters.viewname, postModel];
            };
        }
Example #3
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultViewLocator"/> class.
 /// </summary>
 /// <param name="viewLocationProvider">An <see cref="IViewLocationProvider"/> instance.</param>
 /// <param name="viewEngines">An <see cref="IEnumerable{T}"/> of <see cref="IViewEngine"/> instances.</param>
 /// <param name="environment">An <see cref="INancyEnvironment"/> instance.</param>
 public DefaultViewLocator(IViewLocationProvider viewLocationProvider, IEnumerable <IViewEngine> viewEngines, INancyEnvironment environment)
 {
     this.viewLocationProvider = viewLocationProvider;
     this.viewEngines          = viewEngines;
     this.invalidCharacters    = Path.GetInvalidFileNameChars().Where(c => c != '/').ToArray();
     this.viewLocationResults  = new List <ViewLocationResult>(this.GetInititialViewLocations());
     this.configuration        = environment.GetValue <ViewConfiguration>();
 }
Example #4
0
        public DefaultViewLocator(IViewLocationProvider viewLocationProvider, IEnumerable<IViewEngine> viewEngines)
        {
            this.viewLocationProvider = viewLocationProvider;
            this.viewEngines = viewEngines;

            // No need to lock here, we get constructed on app startup
            this.viewLocationResults = new List<ViewLocationResult>(this.GetInititialViewLocations());
        }
Example #5
0
 /// <summary>
 /// Initializes a new instance of the <see cref="DefaultViewLocator"/> class.
 /// </summary>
 /// <param name="viewLocationProvider">An <see cref="IViewLocationProvider"/> instance.</param>
 /// <param name="viewEngines">An <see cref="IEnumerable{T}"/> of <see cref="IViewEngine"/> instances.</param>
 /// <param name="environment">An <see cref="INancyEnvironment"/> instance.</param>
 public DefaultViewLocator(IViewLocationProvider viewLocationProvider, IEnumerable<IViewEngine> viewEngines, INancyEnvironment environment)
 {
     this.viewLocationProvider = viewLocationProvider;
     this.viewEngines = viewEngines;
     this.invalidCharacters = Path.GetInvalidFileNameChars().Where(c => c != '/').ToArray();
     this.viewLocationResults = new List<ViewLocationResult>(this.GetInititialViewLocations());
     this.configuration = environment.GetValue<ViewConfiguration>();
 }
        public DefaultModule(IArticleReader articleReader, IRouteLocatorProvider routeLocatorProvider, IViewLocationProvider viewLocationProvider)
        {
            _articleReader = articleReader;
            _routeLocatorProvider = routeLocatorProvider;
            _viewLocationProvider = viewLocationProvider;

            SetupDateRoutes();
            SetupStaticRoutes();
        }
Example #7
0
        public DefaultViewLocator(IViewLocationProvider viewLocationProvider, IEnumerable<IViewEngine> viewEngines)
        {
            this.viewLocationProvider = viewLocationProvider;
            this.viewEngines = viewEngines;

            this.invalidCharacters = Path.GetInvalidFileNameChars().Where(c => c != '/').ToArray();

            // No need to lock here, we get constructed on app startup
            this.viewLocationResults = new List<ViewLocationResult>(this.GetInititialViewLocations());
        }
        public DefaultViewLocator(IViewLocationProvider viewLocationProvider, IEnumerable <IViewEngine> viewEngines)
        {
            this.viewLocationProvider = viewLocationProvider;
            this.viewEngines          = viewEngines;

            this.invalidCharacters = Path.GetInvalidFileNameChars().Where(c => c != '/').ToArray();

            // No need to lock here, we get constructed on app startup
            this.viewLocationResults = new List <ViewLocationResult>(this.GetInititialViewLocations());
        }
 public DefaultViewLocationCache(IViewLocationProvider viewLocationProvider, IEnumerable <IViewEngine> viewEngines)
 {
     this.viewLocationProvider = viewLocationProvider;
     this.viewEngines          = viewEngines;
     this.locatedViews         = GetLocatedViews();
 }
 public DefaultViewLocationCache(IViewLocationProvider viewLocationProvider, IEnumerable<IViewEngine> viewEngines)
 {
     this.viewLocationProvider = viewLocationProvider;
     this.viewEngines = viewEngines;
     this.locatedViews = GetLocatedViews();
 }
 private static DefaultViewLocationCache CreateViewLocationCache(IViewLocationProvider viewLocationProvider, IEnumerable<IViewEngine> viewEngines)
 {
     return new DefaultViewLocationCache(viewLocationProvider, viewEngines);
 }
 private static DefaultViewLocationCache CreateViewLocationCache(IViewLocationProvider viewLocationProvider, IEnumerable <IViewEngine> viewEngines)
 {
     return(new DefaultViewLocationCache(viewLocationProvider, viewEngines));
 }
Example #13
0
 /// <summary>
 /// Configures the bootstrapper to use the provided instance of <see cref="IViewLocationProvider"/>.
 /// </summary>
 /// <param name="viewLocationProvider">The <see cref="IViewLocationProvider"/> instance that should be used by the bootstrapper.</param>
 /// <returns>An instance to the current <see cref="FakeNancyBootstrapperConfigurator"/>.</returns>
 public FakeNancyBootstrapperConfigurator ViewLocationProvider(IViewLocationProvider viewLocationProvider)
 {
     this.bootstrapper.configuredEnumerableInstances[typeof(IViewLocationProvider)] = new[] { viewLocationProvider };
     return(this);
 }