Вы не можете выбрать более 25 тем Темы должны начинаться с буквы или цифры, могут содержать дефисы(-) и должны содержать не более 35 символов.

HelpController.cs 1.9KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. using System;
  2. using System.Web.Http;
  3. using System.Web.Mvc;
  4. using CacheControl_test.Areas.HelpPage.ModelDescriptions;
  5. using CacheControl_test.Areas.HelpPage.Models;
  6. namespace CacheControl_test.Areas.HelpPage.Controllers
  7. {
  8. /// <summary>
  9. /// The controller that will handle requests for the help page.
  10. /// </summary>
  11. public class HelpController : Controller
  12. {
  13. private const string ErrorViewName = "Error";
  14. public HelpController()
  15. : this(GlobalConfiguration.Configuration)
  16. {
  17. }
  18. public HelpController(HttpConfiguration config)
  19. {
  20. Configuration = config;
  21. }
  22. public HttpConfiguration Configuration { get; private set; }
  23. public ActionResult Index()
  24. {
  25. ViewBag.DocumentationProvider = Configuration.Services.GetDocumentationProvider();
  26. return View(Configuration.Services.GetApiExplorer().ApiDescriptions);
  27. }
  28. public ActionResult Api(string apiId)
  29. {
  30. if (!String.IsNullOrEmpty(apiId))
  31. {
  32. HelpPageApiModel apiModel = Configuration.GetHelpPageApiModel(apiId);
  33. if (apiModel != null)
  34. {
  35. return View(apiModel);
  36. }
  37. }
  38. return View(ErrorViewName);
  39. }
  40. public ActionResult ResourceModel(string modelName)
  41. {
  42. if (!String.IsNullOrEmpty(modelName))
  43. {
  44. ModelDescriptionGenerator modelDescriptionGenerator = Configuration.GetModelDescriptionGenerator();
  45. ModelDescription modelDescription;
  46. if (modelDescriptionGenerator.GeneratedModels.TryGetValue(modelName, out modelDescription))
  47. {
  48. return View(modelDescription);
  49. }
  50. }
  51. return View(ErrorViewName);
  52. }
  53. }
  54. }