/// <summary>
        /// Get list of custom filters
        /// </summary>
        /// <returns>List of filters</returns>
        public IEnumerable<CustomFilter> GetCustomFilters()
        {
            if (!Security.IsAuthorizedTo(Rights.AccessAdminPages))
                throw new UnauthorizedAccessException();

            var filterList = new List<CustomFilter>();
            try
            {
                CustomFilters = ExtensionManager.GetSettings("MetaExtension", "BeCustomFilters");
                DataTable dt = CustomFilters.GetDataTable();

                foreach (DataRow row in dt.Rows)
                {
                    var f = new CustomFilter
                    {
                        Name = row["Name"].ToString(),
                        FullName = row["FullName"].ToString(),
                        Checked = int.Parse(row["Checked"].ToString()),
                        Spam = int.Parse(row["Cought"].ToString()),
                        Mistakes = int.Parse(row["Reported"].ToString())
                    };

                    var ext = ExtensionManager.GetExtension(f.Name);
                    f.Enabled = ext == null ? true : ext.Enabled;

                    filterList.Add(f);
                }
            }
            catch (Exception ex)
            {
                Utils.Log("CustomFilterRepository.GetCustomFilters(): " + ex.Message);
            }
            return filterList;
        }
        /// <summary>
        /// Comment filters list
        /// </summary>
        /// <param name="take"></param>
        /// <param name="skip"></param>
        /// <param name="filter"></param>
        /// <param name="order"></param>
        /// <returns>List of comment filters</returns>
        public IEnumerable<CommentFilterItem> Find(int take = 10, int skip = 0, string filter = "", string order = "")
        {
            if (!Security.IsAuthorizedTo(BlogEngine.Core.Rights.AccessAdminPages))
                throw new System.UnauthorizedAccessException();

            var filterList = new List<CommentFilterItem>();
            try
            {
                Filters = ExtensionManager.GetSettings("MetaExtension", "BeCommentFilters");
                DataTable dt = Filters.GetDataTable();

                foreach (DataRow row in dt.Rows)
                {
                    var f = new CommentFilterItem
                    {
                        Id = Guid.Parse(row["Id"].ToString()),
                        Action = row["Action"].ToString(),
                        Subject = row["Subject"].ToString(),
                        Operation = row["Operator"].ToString(),
                        Filter = row["Filter"].ToString()
                    };
                    filterList.Add(f);
                }

                if (take == 0) take = filterList.Count;
                if (string.IsNullOrEmpty(filter)) filter = "1==1";
                if (string.IsNullOrEmpty(order)) order = "Filter";

                var items = new List<CommentFilterItem>();
                var query = filterList.AsQueryable().Where(filter);

                foreach (var item in query.OrderBy(order).Skip(skip).Take(take))
                    items.Add(item);

                return items;
            }
            catch (Exception ex)
            {
                Utils.Log("CommentFilterRepository.Find(): " + ex.Message);
            }
            return filterList;
        }
        /// <summary>
        /// The init custom filters.
        /// </summary>
        private static void InitCustomFilters()
        {
            var settings = new ExtensionSettings("BeCustomFilters");

            settings.AddParameter("FullName", "Name", 100, true, true);
            settings.AddParameter("Name");
            settings.AddParameter("Checked");
            settings.AddParameter("Cought");
            settings.AddParameter("Reported");
            settings.AddParameter("Priority");

            customFilters = ExtensionManager.InitSettings("MetaExtension", settings);
            if (customFilters == null)
            {
                return;
            }

            var dt = customFilters.GetDataTable();
            var codeAssemblies = Utils.CodeAssemblies();

            foreach (var type in
                codeAssemblies.Cast<Assembly>().Select(a => a.GetTypes()).SelectMany(
                    types => (from type in types
                              where type.GetInterface("BlogEngine.Core.ICustomFilter") != null
                              let found = dt.Rows.Cast<DataRow>().Any(row => row[0].ToString() == type.Name)
                              where !found
                              select type)))
            {
                // if new filter found in the assembly, add it to settings
                if (!customFilters.IsKeyValueExists(type.FullName))
                {
                    customFilters.AddValues(new[] { type.FullName, type.Name, "0", "0", "0", "0" });
                    ExtensionManager.SaveSettings("MetaExtension", customFilters);
                }
            }
        }