/// <summary>
        /// Saves the settings.
        /// </summary>
        /// <param name="settings">The settings.</param>
        /// <returns>Whether the save action succeeded.</returns>
        public bool SaveSettings(ClonedContentProviderSettings settings)
        {
            if (settings == null)
            {
                return false;
            }

            try
            {
                ClonedContentProviderSettings currentSettings = this.Get(settings.Name);

                if (currentSettings == null)
                {
                    Store.Save(settings);
                }
                else
                {
                    Store.Save(settings, currentSettings.Id); 
                }
            }
            catch (Exception)
            {
                return false;
            }

            return true;
        }
        /// <summary>
        /// Adds the provider.
        /// </summary>
        /// <param name="root">The root.</param>
        /// <param name="entryPoint">The entry point.</param>
        /// <param name="providerName">Name of the provider.</param>
        /// <param name="categoryList">The category list.</param>
        /// <returns>
        ///   <c>true</c> if [the provider has been attached]; otherwise, <c>false</c>.
        /// </returns>
        /// <exception cref="System.InvalidOperationException">Content provider for this node already attached.
        /// or
        /// Content provider with same name already attached.</exception>
        public static bool AddProvider(int root, int entryPoint, string providerName, CategoryList categoryList)
        {
            string name = string.Format(CultureInfo.InvariantCulture, "{0}-ClonedContent-{1}-{2}", providerName, root, entryPoint);

            IQueryable<ClonedContentProviderSettings> providerCollection = SettingsRepository.Instance.GetAll().AsQueryable();

            if (providerCollection.Count(pc => pc.EntryPoint.Equals(entryPoint)) > 0)
            {
                // A provider is already attached to this node.
                throw new InvalidOperationException("Content provider for this node already attached.");
            }

            if (providerCollection.Count(pc => pc.Name.Equals(name)) > 0)
            {
                // A provider with the same name already exists.
                throw new InvalidOperationException("Content provider with same name already attached.");
            }

            CategoryList categories = categoryList ?? new CategoryList();

            ClonedContentProvider provider = new ClonedContentProvider(
                name, 
                new PageReference(root), 
                new PageReference(entryPoint), 
                categories);

            IContentProviderManager providerManager = ServiceLocator.Current.GetInstance<IContentProviderManager>();

            ClonedContentProviderSettings contentProviderSettings = new ClonedContentProviderSettings
                                                                  {
                                                                      Name = name, 
                                                                      EntryPoint = entryPoint, 
                                                                      Root = root, 
                                                                      CategoryList =
                                                                          string.Join(
                                                                              ",", 
                                                                              categories)
                                                                  };

            providerManager.ProviderMap.AddProvider(provider);

            SettingsRepository.Instance.SaveSettings(contentProviderSettings);

            CacheManager.Clear();

            return true;
        }
        /// <summary>
        /// Deletes the provider setting.
        /// </summary>
        /// <param name="providerSettings">The provider settings.</param>
        /// <returns>Whether the delete action succeeded.</returns>
        public bool Delete(ClonedContentProviderSettings providerSettings)
        {
            try
            {
                Store.Delete(providerSettings);
            }
            catch (InvalidOperationException)
            {
                return false;
            }

            return true;
        }