コード例 #1
0
 /// <summary>
 /// Get custom widgets for the given area
 /// Return null if custom widgets are unspecified
 /// </summary>
 /// <param name="areaId">Area id</param>
 /// <returns></returns>
 public virtual IList <TemplateWidget> GetCustomWidgets(string areaId)
 {
     return(CustomWidgetsCache.GetOrCreate(areaId, () => {
         var file = GetCustomWidgetsFile(areaId);
         if (file.Exists)
         {
             return JsonConvert.DeserializeObject <List <TemplateWidget> >(file.ReadAllText());
         }
         return null;
     }, CustomWidgetsCacheTime));
 }
コード例 #2
0
        /// <summary>
        /// Set custom widgets for the given area
        /// If `widgets` is null then remove the specification
        /// </summary>
        /// <param name="areaId">Area id</param>
        /// <param name="widgets">Custom widgets</param>
        public virtual void SetCustomWidgets(string areaId, IList <TemplateWidget> widgets)
        {
            // Remove cache
            CustomWidgetsCache.Remove(areaId);
            // Write to file
            var file = GetCustomWidgetsFile(areaId);

            if (widgets != null)
            {
                file.WriteAllText(JsonConvert.SerializeObject(widgets, Formatting.Indented));
            }
            else
            {
                file.Delete();
            }
        }
コード例 #3
0
        /// <summary>
        /// Set custom widgets for the given area
        /// If `widgets` is null then remove the specification
        /// </summary>
        /// <param name="areaId">Area id</param>
        /// <param name="widgets">Custom widgets</param>
        public virtual void SetCustomWidgets(string areaId, IList <TemplateWidget> widgets)
        {
            // Remove cache
            CustomWidgetsCache.Remove(areaId);
            // Write to file
            var path = GetCustomWidgetsJsonPath(areaId);

            PathUtils.EnsureParentDirectory(path);
            if (widgets != null)
            {
                File.WriteAllText(path, JsonConvert.SerializeObject(widgets, Formatting.Indented));
            }
            else
            {
                File.Delete(path);
            }
        }
コード例 #4
0
 /// <summary>
 /// Clear cache
 /// </summary>
 public virtual void ClearCache()
 {
     WidgetInfoCache.Clear();
     CustomWidgetsCache.Clear();
     WidgetRenderCache.Clear();
 }