internal static IEnumerable <IPublishedContent> ConvertSearchResultToPublishedContent( this IEnumerable <SearchResult> results, IPublishedStore store) { //TODO: The search result has already returned a result which SHOULD include all of the data to create an IPublishedContent, // however thsi is currently not the case: // http://examine.codeplex.com/workitem/10350 var list = new List <IPublishedContent>(); foreach (var result in results.OrderByDescending(x => x.Score)) { var doc = store.GetDocumentById( UmbracoContext.Current, result.Id); if (doc == null) { continue; //skip if this doesn't exist in the cache } doc.Properties.Add( new PropertyResult("examineScore", result.Score.ToString(), Guid.Empty, PropertyResultType.CustomProperty)); list.Add(doc); } return(list); }
private dynamic DocumentById(string id, IPublishedStore store, object ifNotFound) { int docId; return(int.TryParse(id, out docId) ? DocumentById(docId, store, ifNotFound) : ifNotFound); }
private dynamic DocumentById(int id, IPublishedStore store, object ifNotFound) { var doc = store.GetDocumentById(UmbracoContext.Current, id); return(doc == null ? ifNotFound : new DynamicPublishedContent(doc).AsDynamic()); }
private IPublishedContent TypedDocumentById(string id, IPublishedStore store) { int docId; return(int.TryParse(id, out docId) ? DocumentById(docId, store, null) : null); }
public PublisherService(IPublishedStore publishedStore, IBackgroundTaskQueue backgroundTaskQueue, IOptions <EventLogOptions> options, ILogger <PublisherService> logger) { _publishedStore = publishedStore; _backgroundTaskQueue = backgroundTaskQueue; _logger = logger; _options = options.Value; }
private dynamic DocumentByIds(IPublishedStore store, params string[] ids) { var nodes = ids.Select(eachId => DocumentById(eachId, store)) .Where(x => !TypeHelper.IsTypeAssignableFrom <DynamicNull>(x)) .Cast <DynamicPublishedContent>(); return(new DynamicPublishedContentList(nodes)); }
private dynamic DocumentById(string id, IPublishedStore store) { int docId; return(int.TryParse(id, out docId) ? DocumentById(docId, store) : new DynamicNull()); }
private dynamic DocumentById(int id, IPublishedStore store) { var doc = store.GetDocumentById(UmbracoContext.Current, id); return(doc == null ? new DynamicNull() : new DynamicPublishedContent(doc).AsDynamic()); }
/// <summary> /// Overloaded method accepting an 'object' type /// </summary> /// <param name="id"></param> /// <param name="store"> </param> /// <param name="ifNotFound"> </param> /// <returns></returns> /// <remarks> /// We accept an object type because GetPropertyValue now returns an 'object', we still want to allow people to pass /// this result in to this method. /// This method will throw an exception if the value is not of type int or string. /// </remarks> private dynamic DocumentById(object id, IPublishedStore store, object ifNotFound) { if (id is string) { return(DocumentById((string)id, store, ifNotFound)); } if (id is int) { return(DocumentById((int)id, store, ifNotFound)); } throw new InvalidOperationException("The value of parameter 'id' must be either a string or an integer"); }
/// <summary> /// Overloaded method accepting an 'object' type /// </summary> /// <param name="id"></param> /// <param name="store"> </param> /// <returns></returns> /// <remarks> /// We accept an object type because GetPropertyValue now returns an 'object', we still want to allow people to pass /// this result in to this method. /// This method will throw an exception if the value is not of type int or string. /// </remarks> private IPublishedContent TypedDocumentById(object id, IPublishedStore store) { if (id is string) { return(TypedDocumentById((string)id, store)); } if (id is int) { return(TypedDocumentById((int)id, store)); } throw new InvalidOperationException("The value of parameter 'id' must be either a string or an integer"); }
internal static IEnumerable<IPublishedContent> ConvertSearchResultToPublishedContent( this IEnumerable<SearchResult> results, IPublishedStore store) { //TODO: The search result has already returned a result which SHOULD include all of the data to create an IPublishedContent, // however thsi is currently not the case: // http://examine.codeplex.com/workitem/10350 var list = new List<IPublishedContent>(); foreach (var result in results.OrderByDescending(x => x.Score)) { var doc = store.GetDocumentById( UmbracoContext.Current, result.Id); if (doc == null) continue; //skip if this doesn't exist in the cache doc.Properties.Add( new PropertyResult("examineScore", result.Score.ToString(), Guid.Empty, PropertyResultType.CustomProperty)); list.Add(doc); } return list; }
private IEnumerable <IPublishedContent> TypedDocumentsbyIds(IPublishedStore store, params string[] ids) { return(ids.Select(eachId => TypedDocumentById(eachId, store))); }
private IPublishedContent TypedDocumentById(int id, IPublishedStore store) { var doc = store.GetDocumentById(UmbracoContext.Current, id); return(doc); }