public MarkdownOwinMiddleware(AppFunc next, MarkdownOwinOptions options)
		{
			if (next == null)
				throw new ArgumentNullException(nameof(next));

			if (options == null)
				throw new ArgumentNullException(nameof(options));

			_next = next;

			var sitemap = ServerContext.Create(options);
			var engine = new RenderingEngine();

			_server = new Server(sitemap, engine);
		}
示例#2
0
		public static ServerContext Create(MarkdownOwinOptions options)
		{
			if (options == null)
				throw new ArgumentNullException(nameof(options));

			var rootDirectoryPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, options.RootDirectory);

			if (!Directory.Exists(rootDirectoryPath))
				throw new ArgumentException("The specified root directory does not exist in the expected location: " + rootDirectoryPath);

			var rootRequestPath = NormalizeConfiguredRootRequestPath(options.RootRequestPath);
			var scanResult = ScanRootDirectoryForRoutes(rootDirectoryPath, rootRequestPath);
			var context = CreateContext(scanResult, options.Http404Behavior, options.RootRequestPath);

			return context;
		}
示例#3
0
        public MarkdownOwinMiddleware(AppFunc next, MarkdownOwinOptions options)
        {
            if (next == null)
            {
                throw new ArgumentNullException(nameof(next));
            }

            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            _next = next;

            var sitemap = ServerContext.Create(options);
            var engine  = new RenderingEngine();

            _server = new Server(sitemap, engine);
        }
示例#4
0
        public static ServerContext Create(MarkdownOwinOptions options)
        {
            if (options == null)
            {
                throw new ArgumentNullException(nameof(options));
            }

            var rootDirectoryPath = Path.Combine(AppDomain.CurrentDomain.SetupInformation.ApplicationBase, options.RootDirectory);

            if (!Directory.Exists(rootDirectoryPath))
            {
                throw new ArgumentException("The specified root directory does not exist in the expected location: " + rootDirectoryPath);
            }

            var rootRequestPath = NormalizeConfiguredRootRequestPath(options.RootRequestPath);
            var scanResult      = ScanRootDirectoryForRoutes(rootDirectoryPath, rootRequestPath);
            var context         = CreateContext(scanResult, options.Http404Behavior, options.RootRequestPath);

            return(context);
        }