MVVM-Samples icon indicating copy to clipboard operation
MVVM-Samples copied to clipboard

Blazor Sample Project

Open gragra33 opened this issue 2 years ago • 2 comments

I have ported the Xamarin project to a Blazor project with minimal changes. Project can be found here: gragra33 / MvvmSampleBlazor

gragra33 avatar Jun 15 '23 08:06 gragra33

Hi @gragra33

Question if u do not mind. Is there a way to add static instance such as:

/// <summary>
/// Gets the current <see cref="App"/> instance in use
/// </summary>
public new static App Current => (App)Application.Current;

so that we can use it with an easy IFilesService filesService = App.Current.Services.GetService<IFilesService>();

instead of DI constructor injection or page injection in Blazor ?

Pinox avatar Jun 26 '23 10:06 Pinox

@Pinox Sorry for the late reply as I was not watching the issues for this Microsoft repo.

The IFilesService interface allows us to abstract the implementation to any implementation. The sample project supports more than one platform as each has a different method of accessing the files.

For your own implementation, there is nothing stopping you from making a bound reference to your implementation in that manny but then you lose the flexibility if you decide to support more than one implementation in the future.

gragra33 avatar Sep 30 '23 02:09 gragra33