Esempio n. 1
0
        private HTemplate getTemplate(WebPanel webp, KBModel model)
        {
            string chave = "";
            bool expire = false;
            if (webp == null)
            {
                return null;
            }
            else
            {
                chave = webp.Guid.ToString();
            }

            if (mModelCache == null || model == null || !mModelCache.Guid.Equals(model.Guid) || mModelCache.VersionId != model.VersionId || mVersionId != model.VersionId)
            {
                mVersionId = model.VersionId;
                mModelCache = model;
                mTemplates.Clear();
                expire = true;
            }
            else if (!webp.IsCurrentVersion)
            {
                expire = true;
            }

            if (mTemplates.ContainsKey(chave))
            {
                if (expire == false)
                {
                    CacheVersion cv = mTemplates[chave];
                    if (!cv.Objeto.IsCurrentVersion)
                    {
                        cv.Objeto = webp;
                        cv.Template = new HTemplate(webp.WebForm.EditableContent);
                    }
                    return cv.Template.Clone();
                }
                else
                {
                    mTemplates.Remove(chave);
                }
            }

            HTemplate template = new HTemplate(webp.WebForm.EditableContent);
            mTemplates.Add(chave, new CacheVersion(webp,template));
            return template.Clone();
        }
Esempio n. 2
0
 public CacheVersion(WebPanel webPanel, HTemplate template)
 {
     mWebPanel = webPanel;
     mTemplate = template;
 }