Example #1
0
 private GetWidgetModelBase GetRetriever(Widget widget)
 {
     using (MiniProfiler.Current.Step("Get Retriever"))
     {
         if (widget == null) return DefaultGetWidgetModel.Instance;
         GetWidgetModelBase retriever = null;
         string typeName = widget.GetType().FullName;
         if (WidgetModelRetrievers.ContainsKey(typeName))
         {
             retriever = _kernel.Get(WidgetModelRetrievers[typeName]) as GetWidgetModelBase;
         }
         return retriever ?? DefaultGetWidgetModel.Instance;
     }
 }
Example #2
0
 public CachingInfo Get(Widget widget)
 {
     using (MiniProfiler.Current.Step("Get caching info"))
     {
         if (widget == null)
         {
             return CachingInfo.DoNotCache;
         }
         var attribute = widget.GetType().GetCustomAttribute<OutputCacheableAttribute>();
         if (attribute == null)
         {
             return CachingInfo.DoNotCache;
         }
         var shouldCache = widget.Cache && widget.CacheLength > 0;
         return new CachingInfo(shouldCache, GetCacheKey(widget, attribute),
             TimeSpan.FromSeconds(widget.CacheLength),
             widget.CacheExpiryType);
     }
 }