Skip to content

Instantly share code, notes, and snippets.

@configureappio
Created January 19, 2020 14:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save configureappio/7cb3c72a026689c79676a7d497042039 to your computer and use it in GitHub Desktop.
Save configureappio/7cb3c72a026689c79676a7d497042039 to your computer and use it in GitHub Desktop.
KelvinMapperLookup.cs
services.AddSingleton<KelvinConverterMapper>(provider => key =>
{
switch ((string.IsNullOrEmpty(key) ? " " : key).ToUpper()[0])
{
case 'C':
return provider.GetRequiredService<CentigradeToKelvinMapper>();
case 'F':
return provider.GetRequiredService<FahrenheitToKelvinMapper>();
case 'R':
return provider.GetRequiredService<RankineToKelvinMapper>();
case 'K':
return provider.GetRequiredService<KelvinToKelvinMapper>();
default:
return null;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment