/// <summary>
 /// When plugin is loaded the bundles for the site need to be built
 /// </summary>
 public void EnsureBundleIntegrity(string key)
 {
     if (!BundleDictionary.ContainsKey(key))
     {
         PageBundle pageBundle = new PageBundle(key);
         BundleDictionary[key] = pageBundle;
     }
     else
     {
         //For now replcae the bundle every three hours, minor performance degredatoin expected
         //when a page is updated
         if (BundleDictionary[key].LastConsistencyCheck.Add(Configuration.BundleTimeout) < DateTime.Now)
         {
             PageBundle pageBundle = new PageBundle(key);
             BundleDictionary[key] = pageBundle;
         }
     }
 }
 /// <summary>
 /// When plugin is loaded the bundles for the site need to be built
 /// </summary>
 public void EnsureBundleIntegrity(string key)
 {
     if (!BundleDictionary.ContainsKey(key))
     {
         PageBundle pageBundle = new PageBundle(key);
         BundleDictionary[key] = pageBundle;
     }
     else
     {
         //For now replcae the bundle every three hours, minor performance degredatoin expected 
         //when a page is updated
         if (BundleDictionary[key].LastConsistencyCheck.Add(Configuration.BundleTimeout) < DateTime.Now)
         {
             PageBundle pageBundle = new PageBundle(key);
             BundleDictionary[key] = pageBundle;
         }
     } 
 }
        public void Process(CQ parsedContent)
        {
            ContentFragmentPageControl contentFragmentPage = ContentFragmentPageControl.GetCurrentContentFragmentPage();

            if (contentFragmentPage != null)
            {
                PageContext currentContext = PublicApi.Url.CurrentContext;

                if (currentContext != null && !string.IsNullOrWhiteSpace(currentContext.UrlName))
                {
                    string key = CreateKey(contentFragmentPage.ThemeTypeId, contentFragmentPage.ThemeName, currentContext.UrlName);

                    EnsureBundleIntegrity(key);

                    //Find the right bundle
                    if (BundleDictionary.ContainsKey(key))
                    {
                        PageBundle bundle = BundleDictionary[key];

                        if (!bundle.BundleRegistered)
                        {
                            if (_initialization.WaitOne(1))
                            {
                                try
                                {
                                    bundle.BuildBundleData(contentFragmentPage, parsedContent);
                                }
                                finally
                                {
                                    _initialization.Release();
                                }
                            }
                            else
                            {
                                return;
                            }
                        }

                        bundle.ProcessDisplayElement(parsedContent);
                    }
                }
            }
        }