Exemplo n.º 1
0
        /// <summary>
        /// Returns a shallow item, instead of the full Sitecore item.
        /// </summary>
        /// <remarks>
        /// This returns a complete item, except for all the fields.
        /// Excluding the fields greatly enhances performance.
        /// </remarks>
        protected virtual Item ConvertUiSearchResultItemToActualItem(SitecoreUISearchResultItem searchResultItem, DataProviderMasterDatabase dataProvider)
        {
            var uri = searchResultItem.Uri ?? new ItemUri(searchResultItem["_uniqueid"]);

            var definition = dataProvider.GetItemDefinition(uri.ItemID, null);

            if (definition == null)
            {
                return(null);
            }

            var item = new Item(definition.ID, new ItemData(definition, uri.Language, uri.Version, new FieldList()),
                                GetMasterDatabase());

            return(item);
        }
Exemplo n.º 2
0
        /// <summary>
        /// converts a sitecore result item to a AR model class
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="resultItem"></param>
        /// <returns></returns>
        public static T CreateAs <T>(this SitecoreUISearchResultItem resultItem) where T : SitecoreItem
        {
            Item item = resultItem.GetItem();

            return(item != null ? (T)item.CreateAs <T>() : null);
        }