WebViewPageExtensions.cs 1006 B

1234567891011121314151617181920212223242526272829
  1. using System.Web.Mvc;
  2. using System.IO;
  3. using System.Text;
  4. using System.Web;
  5. using BuildOurOwnBabylonJSServer.Controllers;
  6. namespace BuildOurOwnBabylonJSServer.Extensions
  7. {
  8. public static class WebViewPageExtensions
  9. {
  10. public static IHtmlString BabylonJSScript(this WebViewPage page,
  11. string relPathToBabylonJSFolder)
  12. {
  13. if (page == null)
  14. return null;
  15. var type = "text/javascript";
  16. var src = page.Url.Action(BuildOurOwnBabylonJSController.GetFileContentActionName,
  17. "BuildOurOwnBabylonJS",
  18. new { rootPath = page.ViewBag.BabylonJSFolder, relPath = relPathToBabylonJSFolder, type = type });
  19. var script = new TagBuilder("script");
  20. script.Attributes.Add("src", src);
  21. script.Attributes.Add("type", type);
  22. return page.Html.Raw(script.ToString(TagRenderMode.Normal));
  23. }
  24. }
  25. }