public void Override_01() { var parts = new List <HighlightedPart>() { new HighlightedPart() { Index = 0, Length = 5 }, new HighlightedPart() { Index = 3, Length = 5 } }; HighlightConverter.Override(parts, 0); Assert.AreEqual(parts.Count, 2); AssertHighlightedPartEqual(parts[0], new HighlightedPart() { Index = 0, Length = 5 }); AssertHighlightedPartEqual(parts[1], new HighlightedPart() { Index = 5, Length = 3 }); }
public void Override_03() { var parts = new List <HighlightedPart>() { new HighlightedPart() { Index = 0, Length = 8 }, new HighlightedPart() { Index = 2, Length = 2 }, new HighlightedPart() { Index = 5, Length = 10 } }; HighlightConverter.Override(parts, 0); Assert.AreEqual(parts.Count, 2); AssertHighlightedPartEqual(parts[0], new HighlightedPart() { Index = 0, Length = 8 }); AssertHighlightedPartEqual(parts[1], new HighlightedPart() { Index = 8, Length = 7 }); }
public void MergeHighlightedParts_01() { var parts = new List <HighlightedPart>() { new HighlightedPart() { Index = 5, Length = 5 } }; var parts2 = new List <HighlightedPart>() { new HighlightedPart() { Index = 2, Length = 5 } }; HighlightConverter.MergeHighlightedParts(parts, parts2); Assert.AreEqual(parts.Count, 2); AssertHighlightedPartEqual(parts[0], new HighlightedPart() { Index = 2, Length = 5 }); AssertHighlightedPartEqual(parts[1], new HighlightedPart() { Index = 7, Length = 3 }); }
public QueryResult <Product> Search(Query query) { var options = new QueryOptions(); AbstractSolrQuery q = new SolrQuery(!string.IsNullOrEmpty(query.SearchText) ? query.SearchText : "*"); options.ExtraParams = new[] { new KeyValuePair <string, string>("df", "description") }; options.Rows = query.NumToReturn ?? DefaultSettings.DefaultNumToReturn; options.StartOrCursor = OffsetConverter.GetOffsetFromCurrentPage(query.Page); options.OrderBy = SortOrderConverter.GetSortOrder(query); string facetToExclude; options.FilterQueries = FilterConverter.GetSolrNetFilters(query, out facetToExclude); options.Facet = FacetConverter.GetSolrNetFacetParameters(query, facetToExclude); options.Highlight = HighlightConverter.GetSolrNetHighlightingParameters(query.SearchText); var results = SolrOperations.Query(q, options); var convertedResults = ResultConverter.GetQueryResult(results); if (convertedResults == null) { convertedResults.ErrorMessages = new[] { "An error occured communicating with the solr instance" }; } return(convertedResults); }
protected virtual void SetHighlightValue(FrameworkElement ctrl, DependencyProperty dpProp, Highlight h, HighlightConverter converter, TypeConverter finalConverter) { if (converter == null) { throw new ArgumentNullException("converter"); } if (finalConverter == null) { throw new ArgumentNullException("finalConverter"); } var value = converter.Convert(h, null, null, null); if (value == Binding.DoNothing) { ctrl.SetValue(dpProp, DependencyProperty.UnsetValue); } else if (value == null) { ctrl.SetValue(dpProp, null); } else if (dpProp.PropertyType.IsAssignableFrom(value.GetType())) { ctrl.SetValue(dpProp, value); } else { ctrl.SetValue(dpProp, finalConverter.ConvertFrom(value)); } }