private static void DoBaseTemplateUpdates([NotNull] Item item, ItemChanges itemChanges)
        {
            var siteSettings = (DynamicSiteSettingsItem)item;

            if (itemChanges == null ||
                !itemChanges.IsFieldModified(siteSettings.SiteDefinitionTemplate.Field.InnerField.ID))
            {
                DynamicSiteManager.PublishItemChanges(item);
                return;
            }

            var changedField = itemChanges.FieldChanges[siteSettings.SiteDefinitionTemplate.Field.InnerField.ID];
            var oldValue     = changedField.OriginalValue;
            var newValue     = changedField.Value;

            if (oldValue.Equals(newValue))
            {
                return;
            }

            if (newValue.IsNullOrEmpty())
            {
                if (item.Fields[changedField.FieldID].ContainsStandardValue)
                {
                    newValue = item.Fields[changedField.FieldID].GetStandardValue();
                }
            }

            if (!newValue.IsNullOrEmpty())
            {
                var newTemplateItem = DynamicSiteSettings.GetCurrentDatabase.GetTemplate(new ID(newValue));

                if (newTemplateItem != null)
                {
                    DynamicSiteManager.AddBaseTemplate(newTemplateItem);
                }
            }

            if (oldValue.IsNullOrEmpty())
            {
                return;
            }
            var oldTemplateItem = DynamicSiteSettings.GetCurrentDatabase.GetTemplate(new ID(oldValue));

            if (oldTemplateItem != null)
            {
                DynamicSiteManager.RemoveBaseTemplate(oldTemplateItem);
            }
        }
        private void ResetDynamicSitesCache([NotNull] Item item)
        {
            //Is Module Disabled at the config level?
            if (DynamicSiteSettings.Disabled)
            {
                return;
            }

            //If Item being deleted is a Dynamic Site, clear the Dynamic Site cache.
            if (!DynamicSiteManager.HasBaseTemplate(item))
            {
                return;
            }

            DynamicSiteManager.PublishItemChanges(item);
            DynamicSiteManager.ClearCache();
        }