private CachedView CheckCachedSharedViewValidity(SharedViewRole role, string sharedViewName, CachedView viewData) { if (_viewLoader.DoesNeedToReloadSharedView(role, sharedViewName, viewData.LoadTimestamp)) { viewData = null; } return(viewData); }
private CachedView LoadSharedView(SharedViewRole role, string sharedViewName, string viewKey, CachedView viewData) { viewData = new CachedView(); using (var viewText = _viewLoader.LoadSharedViewText(role, sharedViewName)) { viewData.ViewType = PrepareView(viewText, viewKey); } viewData.LoadTimestamp = DateTime.UtcNow; return(viewData); }
private ViewBase FindAndExecuteSharedView(SharedViewRole role, string sharedViewName, TextWriter output, ControllerBase controller, ViewBase parentView, Stream bodyContent, Dictionary <string, Action> sections) { var viewKey = "/#" + sharedViewName; CachedView viewData; viewData = GetCachedView(viewKey); if (viewData != null) { viewData = CheckCachedSharedViewValidity(role, sharedViewName, viewData); } if (viewData == null) { viewData = LoadSharedView(role, sharedViewName, viewKey, viewData); SaveViewInCache(viewKey, viewData); } var view = (ViewBase)Activator.CreateInstance(viewData.ViewType); InitializeView(controller, parentView, view, output, new RenderContext { BodyContent = bodyContent, Sections = sections }); view.Execute(); return(view); }
public System.IO.TextReader LoadSharedViewText(SharedViewRole role, string sharedViewName) { return(new System.IO.StringReader(_views[sharedViewName])); }
public bool DoesNeedToReloadSharedView(SharedViewRole role, string sharedViewName, DateTime previousLoadTime) { return(false); }
private CachedView LoadSharedView(SharedViewRole role, string sharedViewName, string viewKey, CachedView viewData) { viewData = new CachedView(); using (var viewText = _viewLoader.LoadSharedViewText(role, sharedViewName)) { viewData.ViewType = PrepareView(viewText, viewKey); } viewData.LoadTimestamp = DateTime.UtcNow; return viewData; }
private ViewBase FindAndExecuteSharedView(SharedViewRole role, string sharedViewName, TextWriter output, ControllerBase controller, ViewBase parentView, Stream bodyContent, Dictionary<string,Action> sections) { var viewKey = "/#" + sharedViewName; CachedView viewData; viewData = GetCachedView(viewKey); if (viewData != null) { viewData = CheckCachedSharedViewValidity(role, sharedViewName, viewData); } if (viewData == null) { viewData = LoadSharedView(role, sharedViewName, viewKey, viewData); SaveViewInCache(viewKey, viewData); } var view = (ViewBase)Activator.CreateInstance(viewData.ViewType); InitializeView(controller, parentView, view, output, new RenderContext { BodyContent = bodyContent,Sections = sections }); view.Execute(); return view; }
private CachedView CheckCachedSharedViewValidity(SharedViewRole role, string sharedViewName, CachedView viewData) { if (_viewLoader.DoesNeedToReloadSharedView(role, sharedViewName, viewData.LoadTimestamp)) { viewData = null; } return viewData; }
public TextReader LoadSharedViewText(SharedViewRole role, string sharedViewName) { var filename = GetSharedFileName(sharedViewName); return(new StreamReader(filename)); }
public bool DoesNeedToReloadSharedView(SharedViewRole role, string sharedViewName, DateTime previousLoadTime) { var filename = GetSharedFileName(sharedViewName); return(new FileInfo(filename).LastWriteTimeUtc > previousLoadTime); }
public System.IO.TextReader LoadSharedViewText(SharedViewRole role, string sharedViewName) { return new System.IO.StringReader(_views[sharedViewName]); }
public bool DoesNeedToReloadSharedView(SharedViewRole role, string sharedViewName, DateTime previousLoadTime) { return false; }
public TextReader LoadSharedViewText(SharedViewRole role, string sharedViewName) { var filename = GetSharedFileName(sharedViewName); return new StreamReader(filename); }
public bool DoesNeedToReloadSharedView(SharedViewRole role, string sharedViewName, DateTime previousLoadTime) { var filename = GetSharedFileName(sharedViewName); return new FileInfo(filename).LastWriteTimeUtc > previousLoadTime; }