diff --git a/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs b/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs index 2dfe6e4165..3ee62783b4 100644 --- a/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs +++ b/samples/CommunityToolkit.Maui.Sample/Pages/Views/CameraView/CameraViewPage.xaml.cs @@ -1,6 +1,6 @@ using System.Diagnostics; +using CommunityToolkit.Maui.Core; using CommunityToolkit.Maui.Sample.ViewModels.Views; -using CommunityToolkit.Maui.Views; namespace CommunityToolkit.Maui.Sample.Pages.Views; diff --git a/src/CommunityToolkit.Maui.Camera/CameraInfo.shared.cs b/src/CommunityToolkit.Maui.Camera/CameraInfo.shared.cs index bb5d4a8b44..13445949cb 100644 --- a/src/CommunityToolkit.Maui.Camera/CameraInfo.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/CameraInfo.shared.cs @@ -1,5 +1,4 @@ using System.Text; -using CommunityToolkit.Maui.Core.Primitives; #if IOS || MACCATALYST using AVFoundation; diff --git a/src/CommunityToolkit.Maui.Camera/CameraManager.android.cs b/src/CommunityToolkit.Maui.Camera/CameraManager.android.cs index edf800459c..c642ca4218 100644 --- a/src/CommunityToolkit.Maui.Camera/CameraManager.android.cs +++ b/src/CommunityToolkit.Maui.Camera/CameraManager.android.cs @@ -7,7 +7,6 @@ using AndroidX.Camera.Lifecycle; using AndroidX.Core.Content; using AndroidX.Lifecycle; -using CommunityToolkit.Maui.Core.Primitives; using CommunityToolkit.Maui.Extensions; using Java.Lang; using Java.Util.Concurrent; diff --git a/src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs b/src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs index 9c905f3285..17941d0cf7 100644 --- a/src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs +++ b/src/CommunityToolkit.Maui.Camera/CameraManager.macios.cs @@ -1,6 +1,5 @@ using System.Diagnostics; using AVFoundation; -using CommunityToolkit.Maui.Core.Primitives; using CommunityToolkit.Maui.Extensions; using CoreMedia; using Foundation; diff --git a/src/CommunityToolkit.Maui.Camera/CameraManager.net.cs b/src/CommunityToolkit.Maui.Camera/CameraManager.net.cs index adf2cbd8e5..41dae1d618 100644 --- a/src/CommunityToolkit.Maui.Camera/CameraManager.net.cs +++ b/src/CommunityToolkit.Maui.Camera/CameraManager.net.cs @@ -1,5 +1,3 @@ -using CommunityToolkit.Maui.Core.Primitives; - namespace CommunityToolkit.Maui.Core; partial class CameraManager diff --git a/src/CommunityToolkit.Maui.Camera/CameraManager.shared.cs b/src/CommunityToolkit.Maui.Camera/CameraManager.shared.cs index fe846cc604..d7703d2572 100644 --- a/src/CommunityToolkit.Maui.Camera/CameraManager.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/CameraManager.shared.cs @@ -1,6 +1,4 @@ -using CommunityToolkit.Maui.Core.Primitives; - -namespace CommunityToolkit.Maui.Core; +namespace CommunityToolkit.Maui.Core; /// /// A class that manages the camera functionality. diff --git a/src/CommunityToolkit.Maui.Camera/CameraManager.tizen.cs b/src/CommunityToolkit.Maui.Camera/CameraManager.tizen.cs index 4fa361c9dc..9d2dd7a1a2 100644 --- a/src/CommunityToolkit.Maui.Camera/CameraManager.tizen.cs +++ b/src/CommunityToolkit.Maui.Camera/CameraManager.tizen.cs @@ -1,5 +1,3 @@ -using CommunityToolkit.Maui.Core.Primitives; - namespace CommunityToolkit.Maui.Core; partial class CameraManager diff --git a/src/CommunityToolkit.Maui.Camera/CameraManager.windows.cs b/src/CommunityToolkit.Maui.Camera/CameraManager.windows.cs index 3c4718b0e5..5edf33fc77 100644 --- a/src/CommunityToolkit.Maui.Camera/CameraManager.windows.cs +++ b/src/CommunityToolkit.Maui.Camera/CameraManager.windows.cs @@ -1,7 +1,5 @@ using System.Runtime.Versioning; -using CommunityToolkit.Maui.Core.Primitives; using CommunityToolkit.Maui.Extensions; -using Microsoft.Maui.Controls.PlatformConfiguration; using Microsoft.UI.Xaml.Controls; using Windows.Media.Capture; using Windows.Media.Capture.Frames; diff --git a/src/CommunityToolkit.Maui.Camera/Extensions/CameraViewExtensions.android.cs b/src/CommunityToolkit.Maui.Camera/Extensions/CameraViewExtensions.android.cs index fbc2db67bb..f4c73fd817 100644 --- a/src/CommunityToolkit.Maui.Camera/Extensions/CameraViewExtensions.android.cs +++ b/src/CommunityToolkit.Maui.Camera/Extensions/CameraViewExtensions.android.cs @@ -2,7 +2,6 @@ using Android.Content.PM; using AndroidX.Camera.Core; using CommunityToolkit.Maui.Core; -using CommunityToolkit.Maui.Core.Primitives; namespace CommunityToolkit.Maui.Extensions; diff --git a/src/CommunityToolkit.Maui.Camera/Extensions/CameraViewExtensions.macios.cs b/src/CommunityToolkit.Maui.Camera/Extensions/CameraViewExtensions.macios.cs index 765a611675..9b5700b635 100644 --- a/src/CommunityToolkit.Maui.Camera/Extensions/CameraViewExtensions.macios.cs +++ b/src/CommunityToolkit.Maui.Camera/Extensions/CameraViewExtensions.macios.cs @@ -1,6 +1,5 @@ using AVFoundation; using CommunityToolkit.Maui.Core; -using CommunityToolkit.Maui.Core.Primitives; namespace CommunityToolkit.Maui.Extensions; diff --git a/src/CommunityToolkit.Maui.Camera/Handlers/CameraViewHandler.shared.cs b/src/CommunityToolkit.Maui.Camera/Handlers/CameraViewHandler.shared.cs index 7a345bc61a..9f4b12f36c 100644 --- a/src/CommunityToolkit.Maui.Camera/Handlers/CameraViewHandler.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Handlers/CameraViewHandler.shared.cs @@ -29,12 +29,7 @@ public partial class CameraViewHandler : ViewHandler and /// commands on the . /// - public static CommandMapper CommandMapper = new(ViewCommandMapper) - { - [nameof(ICameraView.CaptureImage)] = MapCaptureImage, - [nameof(ICameraView.StartCameraPreview)] = MapStartCameraPreview, - [nameof(ICameraView.StopCameraPreview)] = MapStopCameraPreview - }; + public static CommandMapper CommandMapper = new(ViewCommandMapper); readonly ICameraProvider cameraProvider = IPlatformApplication.Current?.Services.GetRequiredService() ?? throw new CameraException($"{nameof(CameraProvider)} not found"); @@ -66,6 +61,9 @@ public void Dispose() GC.SuppressFinalize(this); } + internal CameraManager CameraManager => cameraManager + ?? throw new InvalidOperationException($"{nameof(CameraManager)} cannot be used until the native view has been created"); + /// /// Creates a platform-specific view that will be rendered on that platform. /// @@ -74,7 +72,7 @@ protected override NativePlatformCameraPreviewView CreatePlatformView() ArgumentNullException.ThrowIfNull(MauiContext); cameraManager = new(MauiContext, VirtualView, cameraProvider, () => Init(VirtualView)); - return (NativePlatformCameraPreviewView)cameraManager.CreatePlatformView(); + return (NativePlatformCameraPreviewView)CameraManager.CreatePlatformView(); // When camera is loaded(switched), map the current flash mode to the platform view, // reset the zoom factor to 1 @@ -90,8 +88,8 @@ protected override async void ConnectHandler(NativePlatformCameraPreviewView pla { base.ConnectHandler(platformView); - await (cameraManager?.ArePermissionsGranted() ?? Task.CompletedTask); - await (cameraManager?.ConnectCamera(CancellationToken.None) ?? Task.CompletedTask); + await CameraManager.ArePermissionsGranted(); + await CameraManager.ConnectCamera(CancellationToken.None); await cameraProvider.RefreshAvailableCameras(CancellationToken.None); } @@ -121,14 +119,14 @@ static async void MapIsAvailable(CameraViewHandler handler, ICameraView view) static void MapIsAvailable(CameraViewHandler handler, ICameraView view) #endif { - var cameraAvailability = (ICameraView)handler.VirtualView; + var cameraView = (ICameraView)handler.VirtualView; #if ANDROID - cameraAvailability.UpdateAvailability(handler.Context); + cameraView.UpdateAvailability(handler.Context); #elif WINDOWS - await cameraAvailability.UpdateAvailability(CancellationToken.None); + await cameraView.UpdateAvailability(CancellationToken.None); #elif IOS || MACCATALYST - cameraAvailability.UpdateAvailability(); + cameraView.UpdateAvailability(); #elif TIZEN throw new NotSupportedException("Tizen is not yet supported"); #elif NET @@ -136,40 +134,23 @@ static void MapIsAvailable(CameraViewHandler handler, ICameraView view) #endif } - static async void MapCaptureImage(CameraViewHandler handler, ICameraView view, object? arg3) - { - await (handler.cameraManager?.TakePicture(CancellationToken.None) ?? ValueTask.CompletedTask); - view.HandlerCompleteTCS.SetResult(); - } - - static async void MapStartCameraPreview(CameraViewHandler handler, ICameraView view, object? arg3) - { - await (handler.cameraManager?.StartCameraPreview(CancellationToken.None) ?? Task.CompletedTask); - view.HandlerCompleteTCS.SetResult(); - } - static async void MapImageCaptureResolution(CameraViewHandler handler, ICameraView view) { - await (handler.cameraManager?.UpdateCaptureResolution(view.ImageCaptureResolution, CancellationToken.None) ?? ValueTask.CompletedTask); + await handler.CameraManager.UpdateCaptureResolution(view.ImageCaptureResolution, CancellationToken.None); } static async void MapSelectedCamera(CameraViewHandler handler, ICameraView view) { - await (handler.cameraManager?.UpdateCurrentCamera(view.SelectedCamera, CancellationToken.None) ?? ValueTask.CompletedTask); - } - - static void MapStopCameraPreview(CameraViewHandler handler, ICameraView view, object? arg3) - { - handler.cameraManager?.StopCameraPreview(); + await handler.CameraManager.UpdateCurrentCamera(view.SelectedCamera, CancellationToken.None); } static void MapCameraFlashMode(CameraViewHandler handler, ICameraView view) { - handler.cameraManager?.UpdateFlashMode(view.CameraFlashMode); + handler.CameraManager.UpdateFlashMode(view.CameraFlashMode); } static void MapZoomFactor(CameraViewHandler handler, ICameraView view) { - handler.cameraManager?.UpdateZoom(view.ZoomFactor); + handler.CameraManager.UpdateZoom(view.ZoomFactor); } } \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Camera/Interfaces/IAsynchronouseHandler.cs b/src/CommunityToolkit.Maui.Camera/Interfaces/IAsynchronouseHandler.cs deleted file mode 100644 index acb0ebeaa8..0000000000 --- a/src/CommunityToolkit.Maui.Camera/Interfaces/IAsynchronouseHandler.cs +++ /dev/null @@ -1,12 +0,0 @@ -namespace CommunityToolkit.Maui.Camera; - -/// -/// Interface that allows asynchronous completion of .NET MAUI Handlers -/// -public interface IAsynchronousHandler -{ - /// - /// A to provide Handlers an asynchronous way to complete - /// - TaskCompletionSource HandlerCompleteTCS { get; } -} \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Camera/Interfaces/ICameraView.shared.cs b/src/CommunityToolkit.Maui.Camera/Interfaces/ICameraView.shared.cs index 43d4b44c7f..625aa51294 100644 --- a/src/CommunityToolkit.Maui.Camera/Interfaces/ICameraView.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Interfaces/ICameraView.shared.cs @@ -1,12 +1,9 @@ -using CommunityToolkit.Maui.Camera; -using CommunityToolkit.Maui.Core.Primitives; - -namespace CommunityToolkit.Maui.Core; +namespace CommunityToolkit.Maui.Core; /// /// Represents a visual element that provides the ability to show a camera preview and capture images. /// -public interface ICameraView : IView, IAsynchronousHandler +public interface ICameraView : IView { /// /// Gets the . @@ -51,18 +48,6 @@ public interface ICameraView : IView, IAsynchronousHandler /// bool IsBusy { get; internal set; } - /// - /// Occurs when an image is captured by the camera. - /// - /// The image data held within a . - void OnMediaCaptured(Stream imageData); - - /// - /// Occurs when an image capture fails. - /// - /// A string containing the reason why the capture attempt failed. - void OnMediaCapturedFailed(string failureReason); - /// /// Triggers the camera to capture an image. /// @@ -79,7 +64,7 @@ public interface ICameraView : IView, IAsynchronousHandler /// To customize the behavior of starting the camera preview, consider overriding the behavior through /// CameraViewHandler.CommandMapper.ReplaceMapping(nameof(ICameraView.StartCameraPreview), ADD YOUR METHOD);. /// - ValueTask StartCameraPreview(CancellationToken token); + Task StartCameraPreview(CancellationToken token); /// /// Stops the camera preview. @@ -96,4 +81,16 @@ public interface ICameraView : IView, IAsynchronousHandler /// /// ValueTask> GetAvailableCameras(CancellationToken token); + + /// + /// Occurs when an image is captured by the camera. + /// + /// The image data held within a . + internal void OnMediaCaptured(Stream imageData); + + /// + /// Occurs when an image capture fails. + /// + /// A string containing the reason why the capture attempt failed. + internal void OnMediaCapturedFailed(string failureReason); } \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Camera/Primitives/CameraFlashMode.shared.cs b/src/CommunityToolkit.Maui.Camera/Primitives/CameraFlashMode.shared.cs index d9cf05a25a..bea84f10e1 100644 --- a/src/CommunityToolkit.Maui.Camera/Primitives/CameraFlashMode.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Primitives/CameraFlashMode.shared.cs @@ -1,4 +1,4 @@ -namespace CommunityToolkit.Maui.Core.Primitives; +namespace CommunityToolkit.Maui.Core; /// /// Enumeration of the possible flash modes supported by the camera. diff --git a/src/CommunityToolkit.Maui.Camera/Primitives/CameraPosition.shared.cs b/src/CommunityToolkit.Maui.Camera/Primitives/CameraPosition.shared.cs index d059fdb95c..4212c844d1 100644 --- a/src/CommunityToolkit.Maui.Camera/Primitives/CameraPosition.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Primitives/CameraPosition.shared.cs @@ -1,4 +1,4 @@ -namespace CommunityToolkit.Maui.Core.Primitives; +namespace CommunityToolkit.Maui.Core; /// /// Enumeration of the possible positions that a camera can be placed. diff --git a/src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs b/src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs index dca577d59a..5cd0b67e02 100644 --- a/src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Primitives/CameraViewDefaults.shared.cs @@ -1,8 +1,8 @@ using System.ComponentModel; using System.Runtime.Versioning; using System.Windows.Input; -using CommunityToolkit.Maui.Core.Primitives; using CommunityToolkit.Maui.Views; + namespace CommunityToolkit.Maui.Core; /// Default Values for "/> @@ -59,6 +59,6 @@ internal static Command CreateStartCameraPreviewCommand(Binda internal static ICommand CreateStopCameraPreviewCommand(BindableObject bindable) { var cameraView = (CameraView)bindable; - return new Command(token => cameraView.StopCameraPreview()); + return new Command(_ => cameraView.StopCameraPreview()); } } \ No newline at end of file diff --git a/src/CommunityToolkit.Maui.Camera/Primitives/MediaCaptureFailedEventArgs.shared.cs b/src/CommunityToolkit.Maui.Camera/Primitives/MediaCaptureFailedEventArgs.shared.cs index d829e7b3ba..213d44187e 100644 --- a/src/CommunityToolkit.Maui.Camera/Primitives/MediaCaptureFailedEventArgs.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Primitives/MediaCaptureFailedEventArgs.shared.cs @@ -1,4 +1,4 @@ -namespace CommunityToolkit.Maui.Views; +namespace CommunityToolkit.Maui.Core; /// /// Event args containing all contextual information related to a media capture failure event. diff --git a/src/CommunityToolkit.Maui.Camera/Primitives/MediaCapturedEventArgs.shared.cs b/src/CommunityToolkit.Maui.Camera/Primitives/MediaCapturedEventArgs.shared.cs index ac2ed8fd49..b03fa4f54d 100644 --- a/src/CommunityToolkit.Maui.Camera/Primitives/MediaCapturedEventArgs.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Primitives/MediaCapturedEventArgs.shared.cs @@ -1,4 +1,4 @@ -namespace CommunityToolkit.Maui.Views; +namespace CommunityToolkit.Maui.Core; /// /// Event args containing all contextual information related to media capture event. diff --git a/src/CommunityToolkit.Maui.Camera/Providers/CameraProvider.android.cs b/src/CommunityToolkit.Maui.Camera/Providers/CameraProvider.android.cs index d12f0bbcb0..f908040cd0 100644 --- a/src/CommunityToolkit.Maui.Camera/Providers/CameraProvider.android.cs +++ b/src/CommunityToolkit.Maui.Camera/Providers/CameraProvider.android.cs @@ -7,7 +7,6 @@ using AndroidX.Camera.Core; using AndroidX.Camera.Lifecycle; using AndroidX.Core.Content; -using CommunityToolkit.Maui.Core.Primitives; using Java.Lang; namespace CommunityToolkit.Maui.Core; diff --git a/src/CommunityToolkit.Maui.Camera/Providers/CameraProvider.macios.cs b/src/CommunityToolkit.Maui.Camera/Providers/CameraProvider.macios.cs index 0b71122c78..1a93631309 100644 --- a/src/CommunityToolkit.Maui.Camera/Providers/CameraProvider.macios.cs +++ b/src/CommunityToolkit.Maui.Camera/Providers/CameraProvider.macios.cs @@ -1,5 +1,4 @@ using AVFoundation; -using CommunityToolkit.Maui.Core.Primitives; using CoreMedia; using CoreVideo; using UIKit; diff --git a/src/CommunityToolkit.Maui.Camera/Providers/CameraProvider.windows.cs b/src/CommunityToolkit.Maui.Camera/Providers/CameraProvider.windows.cs index b07ecbcddc..b25c54b4d8 100644 --- a/src/CommunityToolkit.Maui.Camera/Providers/CameraProvider.windows.cs +++ b/src/CommunityToolkit.Maui.Camera/Providers/CameraProvider.windows.cs @@ -1,4 +1,4 @@ -using CommunityToolkit.Maui.Core.Primitives; + using CommunityToolkit.Maui.Extensions; using Windows.Devices.Enumeration; using Windows.Media.Capture; diff --git a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs index d2b010cac9..cdfbcacc5f 100644 --- a/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs +++ b/src/CommunityToolkit.Maui.Camera/Views/CameraView.shared.cs @@ -1,9 +1,8 @@ using System.ComponentModel; using System.Runtime.Versioning; using System.Windows.Input; -using CommunityToolkit.Maui.Camera; using CommunityToolkit.Maui.Core; -using CommunityToolkit.Maui.Core.Primitives; +using CommunityToolkit.Maui.Core.Handlers; namespace CommunityToolkit.Maui.Views; @@ -14,7 +13,6 @@ namespace CommunityToolkit.Maui.Views; [SupportedOSPlatform("android21.0")] [SupportedOSPlatform("ios")] [SupportedOSPlatform("maccatalyst")] -[SupportedOSPlatform("tizen")] public partial class CameraView : View, ICameraView { static readonly BindablePropertyKey isAvailablePropertyKey = @@ -83,8 +81,6 @@ public partial class CameraView : View, ICameraView readonly WeakEventManager weakEventManager = new(); - TaskCompletionSource handlerCompletedTCS = new(); - /// /// Event that is raised when the camera capture fails. /// @@ -192,20 +188,7 @@ bool ICameraView.IsBusy set => SetValue(isCameraBusyPropertyKey, value); } - [EditorBrowsable(EditorBrowsableState.Never)] - TaskCompletionSource IAsynchronousHandler.HandlerCompleteTCS => handlerCompletedTCS; - - /// - public void OnMediaCaptured(Stream imageData) - { - weakEventManager.HandleEvent(this, new MediaCapturedEventArgs(imageData), nameof(MediaCaptured)); - } - - /// - public void OnMediaCapturedFailed(string failureReason) - { - weakEventManager.HandleEvent(this, new MediaCaptureFailedEventArgs(failureReason), nameof(MediaCaptureFailed)); - } + private protected new CameraViewHandler Handler => (CameraViewHandler)(base.Handler ?? throw new InvalidOperationException("Unable to retrieve Handler")); /// public async ValueTask> GetAvailableCameras(CancellationToken token) @@ -224,31 +207,25 @@ public async ValueTask> GetAvailableCameras(Cancellati } /// - public async ValueTask CaptureImage(CancellationToken token) - { - handlerCompletedTCS.TrySetCanceled(token); - - handlerCompletedTCS = new(); - Handler?.Invoke(nameof(ICameraView.CaptureImage)); - - await handlerCompletedTCS.Task.WaitAsync(token); - } + public ValueTask CaptureImage(CancellationToken token) => + Handler.CameraManager.TakePicture(token); /// - public async ValueTask StartCameraPreview(CancellationToken token) - { - handlerCompletedTCS.TrySetCanceled(token); + public Task StartCameraPreview(CancellationToken token) => + Handler.CameraManager.StartCameraPreview(token); - handlerCompletedTCS = new(); - Handler?.Invoke(nameof(ICameraView.StartCameraPreview)); + /// + public void StopCameraPreview() => + Handler.CameraManager.StopCameraPreview(); - await handlerCompletedTCS.Task.WaitAsync(token); + void ICameraView.OnMediaCaptured(Stream imageData) + { + weakEventManager.HandleEvent(this, new MediaCapturedEventArgs(imageData), nameof(MediaCaptured)); } - /// - public void StopCameraPreview() + void ICameraView.OnMediaCapturedFailed(string failureReason) { - Handler?.Invoke(nameof(ICameraView.StopCameraPreview)); + weakEventManager.HandleEvent(this, new MediaCaptureFailedEventArgs(failureReason), nameof(MediaCaptureFailed)); } static object CoerceZoom(BindableObject bindable, object value) diff --git a/src/CommunityToolkit.Maui.UnitTests/Views/CameraView/CameraViewTests.cs b/src/CommunityToolkit.Maui.UnitTests/Views/CameraView/CameraViewTests.cs index bc739198ab..fe8727e275 100644 --- a/src/CommunityToolkit.Maui.UnitTests/Views/CameraView/CameraViewTests.cs +++ b/src/CommunityToolkit.Maui.UnitTests/Views/CameraView/CameraViewTests.cs @@ -56,7 +56,7 @@ public void OnMediaCaptured_RaisesMediaCapturedEvent() cameraView.MediaCaptured += (sender, args) => eventRaised = true; var imageData = new MemoryStream(); - cameraView.OnMediaCaptured(imageData); + ((ICameraView)cameraView).OnMediaCaptured(imageData); Assert.True(eventRaised); } @@ -70,7 +70,7 @@ public async Task OnMediaCapturedFailed_RaisesMediaCaptureFailedEvent() var mediaCaptureFailedTcs = new TaskCompletionSource(); cameraView.MediaCaptureFailed += HandleMediaCaptureFailed; - cameraView.OnMediaCapturedFailed(failureMessage); + ((ICameraView)cameraView).OnMediaCapturedFailed(failureMessage); var mediaCaptureFailedEventArgs = await mediaCaptureFailedTcs.Task;