CommonHelpers 1.0.7

A small library containing frequently reused classes, infrustructure and data services to help build reliable demo applications faster.

There is a newer version of this package available.
See the version list below for details.
Install-Package CommonHelpers -Version 1.0.7
dotnet add package CommonHelpers --version 1.0.7
<PackageReference Include="CommonHelpers" Version="1.0.7" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CommonHelpers --version 1.0.7
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

CommonHelpers

This is a small NET Standard 2.0 helper library to reuse code that I write several times a day in demo projects.

Nuget: CommonHelpers on NuGet

Highlights

Collections

Special collection types that help in special scenarios (e.g. ObservableQueue and ObservableRangeCollection).

Common

This folder has some of the most frequently used classes (i.e. BindableBase, ViewModelBase, JsonHelper).

Extensions

Extensions for commonly used objects like string, DateTime, enum. There are also some special extensions for File, Exception and Color. Finally, there's a unqiue helper, HttpClientExtensions which provides download progress and helper method to POST image data.

MVVM

Platform agnostic MVVM classes like DelegateCommand and RelayCommand

Services

To make testing UI controls easier by quickly providing well formatted data from offline sample data and online API endpoints. This is really useful for quickly testing Load On Demand scenarios.

  • BingImageService
  • ComicVineApiService**
  • SampleDataService
  • XkcdApiService
Examples
Sample Data Service

Sample Data Service

var sampleDataService = new SampleDataService();

BarSeriesData.AddRange(sampleDataService.GenerateCategoricalData());
ScatterSeriesData.AddRange(sampleDataService.GenerateScatterPointData());
LineSeriesData.AddRange(sampleDataService.GenerateDateTimeMinuteData());
SplineAreaSeriesData.AddRange(sampleDataService.GenerateDateTimeDayData());
People.AddRange(sampleDataService.GeneratePeopleData());

BingImageService

Bing ImageService

using (var bingImageService = new BingImageService())
{
    var result = await bingImageService.GetBingImageOfTheDayAsync();
    image.Source = new UriImageSource{Uri = result};
}

ComicVineApiService

ComicVine API Service

var comicVineService = new ComicVineApiService(ApiKeys.ComicVineApiKey, ApiKeys.UniqueUserAgentString);

var apiResult = await comicVineService.GetCharactersAsync(CurrentCharactersCount);
CurrentCharactersCount = apiResult.Offset + apiResult.NumberOfPageResults;
TotalCharactersCount = apiResult.NumberOfTotalResults;

var characters = apiResult.Results;

xkcd API Service

xkcd Image Service

var xkcdService = new XkcdApiService();

// to fetch a comic, get the latest or pass a specific comic ID
XkcdComic xkcdComic;

if (lastXkcdComicNumber == 0)
{
    xkcdComic = await xkcdService.GetNewestComicAsync();
}
else
{
    xkcdComic = await xkcdService.GetComicAsync(lastXkcdComicNumber - 1);
}

lastXkcdComicNumber = xkcdComic.Num;

// This is an `ObservableQueue` (located in CommonHelpers.Collections)      
XkcdComics.Enqueue(xkcdComic);


** Note: Most services do not require an API key, just new up the class and go. To prevent any confusion, any services that need an API key will require it in the constructor.*

CommonHelpers

This is a small NET Standard 2.0 helper library to reuse code that I write several times a day in demo projects.

Nuget: CommonHelpers on NuGet

Highlights

Collections

Special collection types that help in special scenarios (e.g. ObservableQueue and ObservableRangeCollection).

Common

This folder has some of the most frequently used classes (i.e. BindableBase, ViewModelBase, JsonHelper).

Extensions

Extensions for commonly used objects like string, DateTime, enum. There are also some special extensions for File, Exception and Color. Finally, there's a unqiue helper, HttpClientExtensions which provides download progress and helper method to POST image data.

MVVM

Platform agnostic MVVM classes like DelegateCommand and RelayCommand

Services

To make testing UI controls easier by quickly providing well formatted data from offline sample data and online API endpoints. This is really useful for quickly testing Load On Demand scenarios.

  • BingImageService
  • ComicVineApiService**
  • SampleDataService
  • XkcdApiService
Examples
Sample Data Service

Sample Data Service

var sampleDataService = new SampleDataService();

BarSeriesData.AddRange(sampleDataService.GenerateCategoricalData());
ScatterSeriesData.AddRange(sampleDataService.GenerateScatterPointData());
LineSeriesData.AddRange(sampleDataService.GenerateDateTimeMinuteData());
SplineAreaSeriesData.AddRange(sampleDataService.GenerateDateTimeDayData());
People.AddRange(sampleDataService.GeneratePeopleData());

BingImageService

Bing ImageService

using (var bingImageService = new BingImageService())
{
    var result = await bingImageService.GetBingImageOfTheDayAsync();
    image.Source = new UriImageSource{Uri = result};
}

ComicVineApiService

ComicVine API Service

var comicVineService = new ComicVineApiService(ApiKeys.ComicVineApiKey, ApiKeys.UniqueUserAgentString);

var apiResult = await comicVineService.GetCharactersAsync(CurrentCharactersCount);
CurrentCharactersCount = apiResult.Offset + apiResult.NumberOfPageResults;
TotalCharactersCount = apiResult.NumberOfTotalResults;

var characters = apiResult.Results;

xkcd API Service

xkcd Image Service

var xkcdService = new XkcdApiService();

// to fetch a comic, get the latest or pass a specific comic ID
XkcdComic xkcdComic;

if (lastXkcdComicNumber == 0)
{
    xkcdComic = await xkcdService.GetNewestComicAsync();
}
else
{
    xkcdComic = await xkcdService.GetComicAsync(lastXkcdComicNumber - 1);
}

lastXkcdComicNumber = xkcdComic.Num;

// This is an `ObservableQueue` (located in CommonHelpers.Collections)      
XkcdComics.Enqueue(xkcdComic);


** Note: Most services do not require an API key, just new up the class and go. To prevent any confusion, any services that need an API key will require it in the constructor.*

Release Notes

- Fixed BindableBase backing store setter
- SampleDataServices fleshed out

  • .NETStandard 2.0

    • No dependencies.

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
1.0.12 472 4/29/2019
1.0.11 218 4/21/2019
1.0.9 164 4/12/2019
1.0.8 351 11/17/2018
1.0.7 354 6/27/2018
1.0.6 261 6/21/2018
1.0.5 249 6/19/2018
1.0.4 259 6/19/2018
1.0.0 257 6/18/2018