Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.70 KB | None | 0 0
  1. private static void AddService(IServiceCollection services, TypeService typeService, Type scopedServiceType,
  2. Type transientServiceType, Type singletonServiceType)
  3. {
  4. if (scopedServiceType.IsAssignableFrom(typeService.Interface))
  5. services.AddScoped(typeService.Interface, typeService.Implementation);
  6. else if (transientServiceType.IsAssignableFrom(typeService.Interface))
  7. services.AddTransient(typeService.Interface, typeService.Implementation);
  8. else if (singletonServiceType.IsAssignableFrom(typeService.Interface))
  9. services.AddSingleton(typeService.Interface, typeService.Implementation);
  10. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement