public static Task <Bitmap> ToBitmap(this IScreenCapture capture) { var serviceProvider = capture.ServiceProvider ?? throw new ArgumentNullException(nameof(capture.ServiceProvider), $"{nameof(capture.ServiceProvider)} is null."); var factory = serviceProvider.GetService <IScreenCaptureBitmapFactory>() ?? throw new NotSupportedException($"{capture.GetType()} does not support {typeof(IScreenCaptureBitmapFactory)}."); return(factory.ToBitmap(capture)); }
private static IScreenCaptureOclImageFactory GetFactory(IScreenCapture capture) { var serviceProvider = capture.ServiceProvider ?? throw new ArgumentNullException(nameof(capture.ServiceProvider), $"{nameof(capture.ServiceProvider)} is null."); var factory = serviceProvider.GetService <IScreenCaptureOclImageFactory>() ?? throw new NotSupportedException($"{capture.GetType()} does not support {typeof(IScreenCaptureOclImageFactory)}."); return(factory); }