diff --git a/Directory.Packages.props b/Directory.Packages.props
index 298f5ba6..2d63211f 100644
--- a/Directory.Packages.props
+++ b/Directory.Packages.props
@@ -5,16 +5,16 @@
-
-
-
+
+
+
-
-
-
-
-
-
+
+
+
+
+
+
diff --git a/samples/Blazor.ExampleConsumer/Components/Pages/ClientPosition.razor b/samples/Blazor.ExampleConsumer/Components/Pages/ClientPosition.razor
index 4d89d350..d119a1d2 100644
--- a/samples/Blazor.ExampleConsumer/Components/Pages/ClientPosition.razor
+++ b/samples/Blazor.ExampleConsumer/Components/Pages/ClientPosition.razor
@@ -1,7 +1,5 @@
@page "/geolocation"
-@inject IGeolocationService Geolocation
-
Geolocation
Geolocation
diff --git a/samples/Blazor.ExampleConsumer/Components/Pages/ClientPosition.razor.cs b/samples/Blazor.ExampleConsumer/Components/Pages/ClientPosition.razor.cs
index 048d70a2..e278fdc8 100644
--- a/samples/Blazor.ExampleConsumer/Components/Pages/ClientPosition.razor.cs
+++ b/samples/Blazor.ExampleConsumer/Components/Pages/ClientPosition.razor.cs
@@ -3,7 +3,7 @@
namespace Blazor.ExampleConsumer.Components.Pages;
-public sealed partial class ClientPosition
+public sealed partial class ClientPosition(IGeolocationService geolocation)
{
readonly JsonSerializerOptions _opts = new()
{
@@ -23,7 +23,7 @@ public sealed partial class ClientPosition
bool _isLoading = true;
protected override void OnInitialized() =>
- Geolocation.GetCurrentPosition(
+ geolocation.GetCurrentPosition(
component: this,
onSuccessCallbackMethodName: nameof(OnPositionReceived),
onErrorCallbackMethodName: nameof(OnPositionError),
diff --git a/samples/Blazor.ExampleConsumer/Components/Pages/ListenToMe.razor.cs b/samples/Blazor.ExampleConsumer/Components/Pages/ListenToMe.razor.cs
index 45cb8452..bc55caa5 100644
--- a/samples/Blazor.ExampleConsumer/Components/Pages/ListenToMe.razor.cs
+++ b/samples/Blazor.ExampleConsumer/Components/Pages/ListenToMe.razor.cs
@@ -3,7 +3,9 @@
namespace Blazor.ExampleConsumer.Components.Pages;
-public sealed partial class ListenToMe : IDisposable
+public sealed partial class ListenToMe(
+ ISpeechRecognitionService speechRecognition,
+ ISessionStorageService sessionStorage) : IDisposable
{
const string TranscriptKey = "listen-to-me-page-transcript";
@@ -12,20 +14,14 @@ public sealed partial class ListenToMe : IDisposable
SpeechRecognitionErrorEvent? _errorEvent;
string? _transcript;
- [Inject]
- public ISpeechRecognitionService SpeechRecognition { get; set; } = null!;
-
- [Inject]
- public ISessionStorageService SessionStorage { get; set; } = null!;
-
protected override void OnInitialized() =>
- _transcript = SessionStorage.GetItem(TranscriptKey);
+ _transcript = sessionStorage.GetItem(TranscriptKey);
protected override async Task OnAfterRenderAsync(bool firstRender)
{
if (firstRender)
{
- await SpeechRecognition.InitializeModuleAsync();
+ await speechRecognition.InitializeModuleAsync();
}
}
@@ -33,14 +29,14 @@ void OnRecognizeSpeechClick()
{
if (_isRecognizingSpeech)
{
- SpeechRecognition.CancelSpeechRecognition(false);
+ speechRecognition.CancelSpeechRecognition(false);
}
else
{
var bcp47Tag = CurrentUICulture.Name;
_recognitionSubscription?.Dispose();
- _recognitionSubscription = SpeechRecognition.RecognizeSpeech(
+ _recognitionSubscription = speechRecognition.RecognizeSpeech(
bcp47Tag,
OnRecognized,
OnError,
@@ -75,7 +71,7 @@ void OnRecognized(string transcript)
_ => $"{_transcript.Trim()} {transcript}".Trim()
};
- SessionStorage.SetItem(TranscriptKey, _transcript);
+ sessionStorage.SetItem(TranscriptKey, _transcript);
StateHasChanged();
}
diff --git a/samples/Blazor.ExampleConsumer/Components/Pages/ReadToMe.razor b/samples/Blazor.ExampleConsumer/Components/Pages/ReadToMe.razor
index b96d0ae3..4d263ae5 100644
--- a/samples/Blazor.ExampleConsumer/Components/Pages/ReadToMe.razor
+++ b/samples/Blazor.ExampleConsumer/Components/Pages/ReadToMe.razor
@@ -46,13 +46,13 @@
Speak
-