Ejemplo n.º 1
0
 public void AddPage(StaticFileGeneratorPage page)
 {
     if (_processed.Add(page.Url))
     {
         _logger.LogInformation("Adding url \"{url}\" to file \"{file}\"", page.Url, page.Path);
         _pages.Enqueue(page);
     }
 }
Ejemplo n.º 2
0
        private void SaveFile(StaticFileGeneratorPage page, MemoryStream memoryStream)
        {
            var filePath  = page.Path.TrimStart('/');
            var fullPath  = Path.Combine(_options.Value.OutputPath, filePath);
            var directory = Path.GetDirectoryName(fullPath);

            if (!Directory.Exists(directory))
            {
                Directory.CreateDirectory(directory);
            }
            File.WriteAllBytes(fullPath, memoryStream.ToArray());
        }
Ejemplo n.º 3
0
        private static IHttpRequestFeature CreateRequest <TContext>(StaticFileGeneratorPage page)
        {
            string path  = page.Url;
            var    i     = path.IndexOf('?');
            string query = null;

            if (i > 0)
            {
                query = path.Substring(i, path.Length - i);
                path  = path.Substring(0, i);
            }
            IHttpRequestFeature httpRequest = new HttpRequestFeature()
            {
                Protocol    = "http",
                Scheme      = "http",
                Method      = "GET",
                Path        = path,
                QueryString = query,
                Body        = new MemoryStream(),
            };

            return(httpRequest);
        }