private static Boolean IsDerived(TemplateItem template, ID templateId)
    {
      if (template == null || ID.IsNullOrEmpty(templateId))
        return false;

      String key = String.Format("template_isderived_cache_{0},{1}", templateId, template.ID);
      if (MemoryCache.Default.Contains(key))
        return (Boolean) MemoryCache.Default[key];

      Boolean isDerived = template.IsDerived(templateId);
      if (!MemoryCache.Default.Contains(key))
      {
        MemoryCache.Default.Add(key, isDerived, new CacheItemPolicy {SlidingExpiration = TimeSpan.FromMinutes(30)});
      }
      return isDerived;
    }
        private static Boolean IsDerived(TemplateItem template, ID templateId)
        {
            if (template == null || ID.IsNullOrEmpty(templateId))
            {
                return(false);
            }

            String key = String.Format("template_isderived_cache_{0},{1}", templateId, template.ID);

            if (MemoryCache.Default.Contains(key))
            {
                return((Boolean)MemoryCache.Default[key]);
            }

            Boolean isDerived = template.IsDerived(templateId);

            if (!MemoryCache.Default.Contains(key))
            {
                MemoryCache.Default.Add(key, isDerived, new CacheItemPolicy {
                    SlidingExpiration = TimeSpan.FromMinutes(30)
                });
            }
            return(isDerived);
        }
示例#3
0
 public static Template GetTemplate([NotNull] this TemplateItem template, [NotNull] ID templateId) => !template.IsDerived(templateId) ? null : TemplateManager.GetTemplate(template);