Skip to content

BeshoyHindy/CommonHelpers

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

68 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

CommonHelpers

This is a cross platform NET Standard 2.0 helper library containing a bunch of helper code that I used to rewrite several times a day while creating sample apps for developers.

By publishing this is as a signed NuGet package I save myself a lot of time, but more importantly, I get to share it with you. Enjoy!

Releases

NuGet.org (stable) Azure Artifacts Feed (preview)
# CommonHelpers package in MainFeed feed in Azure Artifacts

CI-CD

Workflow Status
main Main
dev Development
prerelease Release to GitHub Packages
release Release to NuGet.org

Azure Pipelines

Branch Status
dev dev
main (default) main
release Build status

Features

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 insights and a helper method to POST image data.

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).

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

ComicVineService requires an API Key (it's free). All other services do not require an API key, just new up the class and start using it.

Examples

Sample Data Service

This is my most frequently used service. You can easily spin up data for Lists, Charts, DataGrids and more with a single method.

var sampleDataService = new SampleDataService();

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

Sample Data Service

BingImageService

Easily fetch the Bing Image of Day.

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

Bing ImageService

xkcd API Service

Getting today's comic by calling GetNewestComic or get any comic by using GetComicAsync(comicNumber).

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);

xkcd Image Service

ComicVineApiService

The ComicVine API is the only service in which you'll need an API key. You pass the key and a unique string name for your app to the constructor. Now you have access to thousands of items like Characters, Videos and more from the 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;

ComicVine API Service

  • Updating to be included in the Arctic Code Vault

About

A set of very frequently used classes, interfaces, and behaviors used in every day projects.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • C# 99.6%
  • PowerShell 0.4%