Skip to content

Getting Started

Giacomo Stelluti Scala edited this page Dec 31, 2019 · 13 revisions

Install

A version quite aligned to GitHub repository can be downloaded from NuGet. It follows the command of .NET Core` CLI tool:

$ dotnet add package PickAll --version 0.17.0-alpha

This will install the specified version of PickAll. In a similar way can be done from Visual Studio Package Manager Console:

PM> Install-Package PickAll -Version 0.17.0-alpha

Context

Each a predefined set of searches or post processing events (defined service) must occur on a search context (SearchContext type). You can get one using Default preconfigured singleton:

var context = SearchContext.Default;

This is the equivalent of:

var context = SearchContext()
                  .With<Goolge>()
                  .With<DuckDuckGo>()
                  .With<Uniqueness>()
                  .With<Order>();

This will create a context that will search results on Google and DuckDuckGo. URL of results will be unique and ordered by description. Something similar can be easly done using the F# friendly constructor:

let context = new SearchContext(typeof<Google>,
                                typeof<DuckDuckGo>,
                                typeof<Uniqueness>,
                                typeof<Order>)

There are also other means to configure services, but no result is created until a call to SearchAsync:

var query = "quantum physics";
var results = await context.SearchAsync(query);

Results

Results gathered and processed by services are a collection of the immutable type ResultInfo, defined with the following public interface:

public class ResultInfo
{
    public string Originator { get; } // The searcher which originated the result.
    public ushort Index { get; } // The result index.
    public string Url { get; } // The result URL.
    public string Description { get; } // The result description.
    public object Data { get; } // // Additional data supplied by the service.
}

After you get your ResultInfo collection you can process it the way you want. E.g. using LINQ:

var urls = from result in results
           where result.Destription.ToLower().Contains("higgs")
           select result.Url;
Clone this wiki locally