-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Dev/startup di #529
Dev/startup di #529
Changes from 4 commits
f935032
accc1b3
36c8351
a1e163a
9319bf5
a3249b9
f9b38a6
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,18 +1,13 @@ | ||
using Maui.Controls.Sample.Controls; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Maui; | ||
|
||
namespace Maui.Controls.Sample | ||
{ | ||
public class MainWindow : Window | ||
{ | ||
public MainWindow() : this(App.Current.Services.GetRequiredService<IPage>()) | ||
{ | ||
} | ||
|
||
public MainWindow(IPage page) | ||
{ | ||
Page = page; | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,44 +1,31 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Linq; | ||
using Maui.Controls.Sample.Services; | ||
using Microsoft.Extensions.Configuration; | ||
using Microsoft.Extensions.DependencyInjection; | ||
using Microsoft.Extensions.Logging; | ||
using Microsoft.Maui; | ||
|
||
namespace Maui.Controls.Sample.ViewModel | ||
{ | ||
public class MainPageViewModel : ViewModelBase | ||
{ | ||
private readonly IConfiguration Configuration; | ||
ITextService textService; | ||
|
||
public MainPageViewModel() : this(new ITextService[] { App.Current.Services.GetService<ITextService>() }) | ||
{ | ||
} | ||
readonly IConfiguration _configuration; | ||
readonly ITextService _textService; | ||
string _text; | ||
|
||
public MainPageViewModel(IEnumerable<ITextService> textServices) | ||
public MainPageViewModel(IConfiguration configuration, IEnumerable<ITextService> textServices) | ||
{ | ||
Configuration = App.Current.Services.GetService<IConfiguration>(); | ||
_configuration = configuration; | ||
_textService = textServices.FirstOrDefault(); | ||
|
||
//var logger = App.Current.Services.GetService<ILogger<MainPageViewModel>>(); | ||
Console.WriteLine($"Value from config: {_configuration["MyKey"]}"); | ||
|
||
//logger.LogInformation("hello"); | ||
|
||
textService = textServices.FirstOrDefault(); | ||
Text = textService.GetText(); | ||
Text = _textService.GetText(); | ||
} | ||
|
||
//public MainPageViewModel(ITextService textService) | ||
//{ | ||
// Text = textService.GetText(); | ||
//} | ||
|
||
string _text; | ||
public string Text | ||
{ | ||
get => _text; | ||
set => SetProperty(ref _text, value); | ||
} | ||
} | ||
} | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
namespace Microsoft.Maui.Controls | ||
{ | ||
public partial class SearchBar : ISearchBar | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. why are you adding this? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Because the SearchBar PR did not add this or register it with the handlers. Seems I missed that when reviewing the PR. Without this it actually throes so I am not even sure how it ran locally... |
||
{ | ||
} | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I have doubts if we should't move this to IFrameworkElement