public Dictionary<SystemEntity, Document> GenerateDocuments(IEnumerable<SystemEntity> entities)
        {
            Dictionary<Type, HashSet<SystemEntity>> dictionary = entities.GroupBy(entity => entity.GetType())
                .ToDictionary(grouping => grouping.Key, grouping => grouping.ToHashSet());

            Dictionary<SystemEntity, Document> documents = new Dictionary<SystemEntity, Document>();
            foreach (Type key in dictionary.Keys)
            {
                Dictionary<int, UniversalSearchItem> items;
                if (!GetUniversalSearchItemTypes.ContainsKey(key))
                    items = new Dictionary<int, UniversalSearchItem>();
                else
                {
                    GetUniversalSearchItemBase getUniversalSearchItem = _kernel.Get(GetUniversalSearchItemTypes[key]) as GetUniversalSearchItemBase;
                    if (getUniversalSearchItem == null)
                        items = new Dictionary<int, UniversalSearchItem>();
                    else
                        items = getUniversalSearchItem.GetSearchItems(dictionary[key])
                            .ToDictionary(searchItem => searchItem.Id, searchItem => searchItem);
                }
                foreach (SystemEntity entity in dictionary[key])
                {
                    UniversalSearchItem item = items.ContainsKey(entity.Id) ? items[entity.Id] : null;
                    documents.Add(entity, item == null ? null : _searchConverter.Convert(item));
                }
            }

            return documents;
        }
        public UniversalSearchItem GenerateItem(SystemEntity entity)
        {
            if (entity == null)
                return null;

            Type type = entity.GetType();
            if (!GetUniversalSearchItemTypes.ContainsKey(type))
                return null;

            GetUniversalSearchItemBase getUniversalSearchItem = _kernel.Get(GetUniversalSearchItemTypes[type]) as GetUniversalSearchItemBase;
            if (getUniversalSearchItem == null)
                return null;

            return getUniversalSearchItem.GetSearchItem(entity);
        }
        private HashSet<Document> GenerateDocuments(HashSet<SystemEntity> entities, Type type)
        {
            using (MiniProfiler.Current.Step("Generating documents for " + type.Name))
            {
                if (entities == null || !entities.Any())
                    return new HashSet<Document>();

                if (!GetUniversalSearchItemTypes.ContainsKey(type))
                    return new HashSet<Document>();

                GetUniversalSearchItemBase getUniversalSearchItem =
                    _kernel.Get(GetUniversalSearchItemTypes[type]) as GetUniversalSearchItemBase;
                if (getUniversalSearchItem == null)
                    return new HashSet<Document>();

                HashSet<UniversalSearchItem> searchItems = getUniversalSearchItem.GetSearchItems(entities);
                if (!searchItems.Any())
                    return new HashSet<Document>();
                using (MiniProfiler.Current.Step("Convert items for " + type.Name))
                {
                    return searchItems.Select(item => _searchConverter.Convert(item)).ToHashSet();
                }
            }
        }