DataCollection is a series of cross-platform observable collections with features like sorting, grouping and filtering and data virtualization techniques like cursor and pagination.
$ dotnet add package C1.DataCollectionThe ComponentOne DataCollection library includes a series of cross-platform observable collections with features like sorting, grouping and filtering and data virtualization techniques like cursor and pagination.
Commonly Used Types:
C1DataCollection is the main class used to sort, filter and group any in memory collection like lists, arrays or observable collection
var collection = new ObservableCollection<Item>();
var dc = new C1DataCollection<Item>(collection);
await dc.SortAsync("Property1", "Property2");
All the data-collections implement INotifyCollectionChanged, when a change happens in the underlying ObservableCollection, the change will be reflected and notified immediatly in the data-collection.
Similarly, the C1DataCollection can be grouped and filtered
var collection = new ObservableCollection<Item>();
var dc = new C1DataCollection<Item>(collection);
await dc.GroupAsync("Property1");
var collection = new ObservableCollection<Item>();
var dc = new C1DataCollection<Item>(collection);
await dc.FilterAsync("Property1", FilterOperation.Contains, "X");
C1VirtualDataCollection and C1CursorDataCollection are two abstract collection that can be used to implement collection whose items are pulled on demand from an external source, typically a network call.
public class YouTubeCollectionView : C1CursorDataCollection<YouTubeVideo>
{
protected override async Task<Tuple<string, IReadOnlyList<YouTubeVideo>>> GetPageAsync(int startingIndex, string pageToken, int? count = null, IReadOnlyList<SortDescription> sortDescriptions = null, FilterExpression filterExpresssion = null, CancellationToken cancellationToken = default(CancellationToken))
{
var client = new HttpClient();
var response = await client.GetAsync(youtubeUrl, cancellationToken);
var videos = new List<YouTubeVideo>();
var serializer = new DataContractJsonSerializer(typeof(YouTubeSearchResult));
var result = serializer.ReadObject(await response.Content.ReadAsStreamAsync()) as YouTubeSearchResult;
foreach (var item in result.Items)
{
videos.Add(new YouTubeVideo(item));
}
return new Tuple<string, IReadOnlyList<YouTubeVideo>>(result.NextPageToken, videos);
}
}There are a series of data collections that can be used to compose other collections
Built-in extensions ease the creation of data collections from know sources like EntityFrameworkCore, Ado.Net and BindingList.
Built-in adapters are used to binding data-collections to native controls.
C1.DataCollection.Serialization includes System.Text.Json converters to serialize and deserialize filter, sort and notification classes to Json.