/// <summary> /// Create a view. /// </summary> /// <param name="context">Request and controller information.</param> /// <param name="viewData">Information that is used in the view</param> /// <param name="writer">Write the view using this writer.</param> public void Render(IControllerContext context, IViewData viewData, TextWriter writer) { string path = context.ViewPath + ".tiny"; _logger.Trace("Rendering '" + path + "'"); TinyView view = GetView(path, viewData.GetHashCode()); if (view == null) { view = CreateView(context, viewData); Add(path, viewData.GetHashCode(), view); } if (view == null) { return; //should throw an exception. } try { view.Render(writer, viewData); } catch (Exception err) { _logger.Error("Failed to call view '" + path + "', reason: " + err); throw; } }
private void Add(string path, int hashCode, TinyView view) { HashedViews views; lock (_cachedViews) { if (!_cachedViews.TryGetValue(path, out views)) { views = new HashedViews(); _cachedViews.Add(path, views); } } views.Add(hashCode, view); }
public void Add(int hashCode, TinyView hashedView) { lock (_hashedViews) _hashedViews[hashCode] = hashedView; }