PlatformServiceCollection.cs 588 B

12345678910111213141516171819
  1. using System.Reflection;
  2. using Microsoft.Extensions.DependencyInjection;
  3. namespace PixiEditor.Platform;
  4. public static class PlatformServiceCollection
  5. {
  6. public static IServiceCollection AddPlatform(this IServiceCollection services)
  7. {
  8. if(IPlatform.Current == null)
  9. throw new InvalidOperationException("No platform was found");
  10. services.AddSingleton(IPlatform.Current);
  11. if (IPlatform.Current.AdditionalContentProvider != null)
  12. services.AddSingleton(IPlatform.Current.AdditionalContentProvider);
  13. return services;
  14. }
  15. }