Skip to content

Latest commit

 

History

History
15 lines (11 loc) · 512 Bytes

dependency-injection.md

File metadata and controls

15 lines (11 loc) · 512 Bytes

Dependency Injection

The SDK is built to work with IoC libraries like MvvmLight and Ninject. To inject an API as a dependency to a viewmodel, you just need to register ILastAuth to an instance of LastAuth:

// mvvmlight
var auth = new LastAuth("apikey", "apisecret");
SimpleIoc.Default.Register<ILastAuth>(() => auth);

// ...

var artistApi = ServiceLocator.Current.GetInstance<ArtistApi>();
var response = await artistApi.GetArtistInfoAsync("The Knife");
var theKnife = artist.Content;