Ejemplo n.º 1
0
 public static IServiceCollection AddPlatformService(this IServiceCollection services, StartupOptions options)
 {
     if (OperatingSystem2.IsIOS /*|| OperatingSystem2.IsWatchOS || OperatingSystem2.IsTvOS*/)
     {
         services.AddSingleton <ApplePlatformServiceImpl>();
         services.AddSingleton <IPlatformService>(s => s.GetRequiredService <ApplePlatformServiceImpl>());
         //services.AddPlatformNotificationService();
         services.TryAddAppleClientHttpPlatformHelperService();
         PlatformToastImpl.TryAddToast(services);
         //if (options.HasGUI)
         //{
         //    services.AddSingleton<IBiometricService, PlatformBiometricServiceImpl>();
         //}
         //services.AddSingleton<IPlatformPageRouteService, AndroidPageRouteServiceImpl>();
     }
     else
     {
         throw new PlatformNotSupportedException();
     }
     return(services);
 }
Ejemplo n.º 2
0
        public static IServiceCollection AddPlatformService(this IServiceCollection services, StartupOptions options)
        {
            if (OperatingSystem2.IsAndroid)
            {
                services.AddSingleton <AndroidPlatformServiceImpl>();
                services.AddSingleton <IPlatformService>(s => s.GetRequiredService <AndroidPlatformServiceImpl>());
                services.AddPlatformNotificationService();
                services.TryAddAndroidClientHttpPlatformHelperService();
                PlatformToastImpl.TryAddToast(services);
                services.AddSingleton <IBiometricService, PlatformBiometricServiceImpl>();
                services.AddSingleton <IFilePickerPlatformService.ISaveFileDialogService, FilePickerPlatformServiceImpl>();
#if __XAMARIN_FORMS__
                services.AddSingleton <IPlatformPageRouteService, AndroidPageRouteServiceImpl>();
#endif
                services.AddSingleton <IDeviceInfoPlatformService, AndroidDeviceInfoPlatformServiceImpl>();
            }
            else
            {
                throw new PlatformNotSupportedException();
            }
            return(services);
        }
Ejemplo n.º 3
0
 /// <summary>
 /// 尝试添加适用于安卓平台的Toast
 /// </summary>
 /// <param name="services"></param>
 /// <returns></returns>
 public static IServiceCollection TryAddToast(this IServiceCollection services)
 => PlatformToastImpl.TryAddToast(services);