@* Generator: WebPagesHelper *@ @using System.Globalization @using System.Web @using Microsoft.Internal.Web.Utils @using Resources @functions { private class FileUploadTracker { private static readonly object _countKey = new object(); private static readonly object _scriptAlreadyRendered = new object(); private readonly HttpContextBase _httpContext; public FileUploadTracker(HttpContextBase httpContext) { _httpContext = httpContext; } public bool ScriptAlreadyRendered { get { bool? rendered = _httpContext.Items[_scriptAlreadyRendered] as bool?; return rendered.HasValue && rendered.Value; } set { _httpContext.Items[_scriptAlreadyRendered] = value; } } public int RenderCount { get { int? count = _httpContext.Items[_countKey] as int?; if (!count.HasValue) { count = 0; } return count.Value; } set { _httpContext.Items[_countKey] = value; } } } } @helper GetHtml(string name = null, int initialNumberOfFiles = 1, bool allowMoreFilesToBeAdded = true, bool includeFormTag = true, string addText = null, string uploadText = null) { @_GetHtml(new HttpContextWrapper(HttpContext.Current), name, initialNumberOfFiles, allowMoreFilesToBeAdded, includeFormTag, addText, uploadText) } @helper _GetHtml(HttpContextBase context, string name, int initialNumberOfFiles, bool allowMoreFilesToBeAdded, bool includeFormTag, string addText, string uploadText) { if (initialNumberOfFiles < 0) { throw new ArgumentOutOfRangeException( "initialNumberOfFiles", String.Format(CultureInfo.InvariantCulture, CommonResources.Argument_Must_Be_GreaterThanOrEqualTo, "0")); } var tracker = new FileUploadTracker(context); int count = tracker.RenderCount++; name = name ?? "fileUpload"; uploadText = uploadText ?? HelpersToolkitResources.FileUpload_Upload; addText = addText ?? HelpersToolkitResources.FileUpload_AddMore; if (allowMoreFilesToBeAdded && !tracker.ScriptAlreadyRendered) { tracker.ScriptAlreadyRendered = true; } if (includeFormTag) { @:
} }