From 847b743a16bab949e286eb1a0653ef0a156212fe Mon Sep 17 00:00:00 2001 From: "kay.one" Date: Thu, 8 Dec 2011 23:59:34 -0800 Subject: [PATCH] cleanup in HtmlIncludeExtentions --- NzbDrone.Web/Helpers/HtmlIncludeExtentions.cs | 29 ++++++++++--------- 1 file changed, 15 insertions(+), 14 deletions(-) diff --git a/NzbDrone.Web/Helpers/HtmlIncludeExtentions.cs b/NzbDrone.Web/Helpers/HtmlIncludeExtentions.cs index a52492617..b56f30bbd 100644 --- a/NzbDrone.Web/Helpers/HtmlIncludeExtentions.cs +++ b/NzbDrone.Web/Helpers/HtmlIncludeExtentions.cs @@ -8,40 +8,41 @@ namespace NzbDrone.Web.Helpers { public static class HtmlIncludeExtentions { - private static string _versionString; - private static bool _isProduction; + private static readonly string versionString; + private static readonly bool isProduction; static HtmlIncludeExtentions() { - _versionString = new EnviromentProvider().Version.ToString().Replace('.', '_'); - _isProduction = EnviromentProvider.IsProduction; + versionString = new EnviromentProvider().Version.ToString().Replace('.', '_'); + isProduction = EnviromentProvider.IsProduction; } public static MvcHtmlString IncludeScript(this HtmlHelper helper, string filename) { var relativePath = "/Scripts/" + filename; VerifyFile(helper, relativePath); - return MvcHtmlString.Create(String.Format("", relativePath, _versionString)); + return MvcHtmlString.Create(String.Format("", relativePath, versionString)); } - + public static MvcHtmlString IncludeCss(this HtmlHelper helper, string filename) { var relativePath = "/Content/" + filename; VerifyFile(helper, relativePath); - return MvcHtmlString.Create(String.Format("", relativePath, _versionString)); + return MvcHtmlString.Create(String.Format("", relativePath, versionString)); } private static void VerifyFile(HtmlHelper helper, string filename) { - if (!_isProduction) - { - var path = helper.ViewContext.RequestContext.HttpContext.Server.MapPath(filename); + if (isProduction) + return; + + var path = helper.ViewContext.RequestContext.HttpContext.Server.MapPath(filename); - if (!File.Exists(path)) - { - throw new FileNotFoundException("static file not found " + path, path); - } + if (!File.Exists(path)) + { + throw new FileNotFoundException("Static file not found " + path, path); } + } } } \ No newline at end of file