Esempio n. 1
0
 private CachedView CheckCachedSharedViewValidity(SharedViewRole role, string sharedViewName, CachedView viewData)
 {
     if (_viewLoader.DoesNeedToReloadSharedView(role, sharedViewName, viewData.LoadTimestamp))
     {
         viewData = null;
     }
     return(viewData);
 }
Esempio n. 2
0
 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);
 }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
 public System.IO.TextReader LoadSharedViewText(SharedViewRole role, string sharedViewName)
 {
     return(new System.IO.StringReader(_views[sharedViewName]));
 }
Esempio n. 5
0
 public bool DoesNeedToReloadSharedView(SharedViewRole role, string sharedViewName, DateTime previousLoadTime)
 {
     return(false);
 }
Esempio n. 6
0
 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;
 }
Esempio n. 7
0
 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;
 }
Esempio n. 8
0
 private CachedView CheckCachedSharedViewValidity(SharedViewRole role, string sharedViewName, CachedView viewData)
 {
     if (_viewLoader.DoesNeedToReloadSharedView(role, sharedViewName, viewData.LoadTimestamp))
     {
         viewData = null;
     }
     return viewData;
 }
Esempio n. 9
0
        public TextReader LoadSharedViewText(SharedViewRole role, string sharedViewName)
        {
            var filename = GetSharedFileName(sharedViewName);

            return(new StreamReader(filename));
        }
Esempio n. 10
0
        public bool DoesNeedToReloadSharedView(SharedViewRole role, string sharedViewName, DateTime previousLoadTime)
        {
            var filename = GetSharedFileName(sharedViewName);

            return(new FileInfo(filename).LastWriteTimeUtc > previousLoadTime);
        }
Esempio n. 11
0
 public System.IO.TextReader LoadSharedViewText(SharedViewRole role, string sharedViewName)
 {
     return new System.IO.StringReader(_views[sharedViewName]);
 }
Esempio n. 12
0
 public bool DoesNeedToReloadSharedView(SharedViewRole role, string sharedViewName, DateTime previousLoadTime)
 {
     return false;
 }
Esempio n. 13
0
 public TextReader LoadSharedViewText(SharedViewRole role, string sharedViewName)
 {
     var filename = GetSharedFileName(sharedViewName);
     return new StreamReader(filename);
 }
Esempio n. 14
0
 public bool DoesNeedToReloadSharedView(SharedViewRole role, string sharedViewName, DateTime previousLoadTime)
 {
     var filename = GetSharedFileName(sharedViewName);
     return new FileInfo(filename).LastWriteTimeUtc > previousLoadTime;
 }