Advertisement
Guest User

Untitled

a guest
Apr 18th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.00 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using System.Web.Mvc;
  6.  
  7. namespace <YOUR_NAMESPACE>
  8. {
  9. public class DocumentModel
  10. {
  11. public string Name { get; set; }
  12. public string Data { get; set; }
  13. }
  14.  
  15. public class DocumentationsController : Controller
  16. {
  17. // GET: Documentations
  18. public ActionResult Index()
  19. {
  20. var docs = new List<DocumentModel>();
  21. foreach(var file in System.IO.Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory + "/Docs", "*.md"))
  22. {
  23. var data = System.IO.File.ReadAllText(file);
  24. var lines = data.Split('\n');
  25. docs.Add(new DocumentModel
  26. {
  27. Name = (lines.Length > 0 && lines[0].StartsWith("#")) ? lines[0].TrimStart('#') : file.Split('/').Last(),
  28. Data = data
  29. });
  30. }
  31. ViewBag.docs = docs;
  32. return View();
  33. }
  34. }
  35. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement