updated module creator templates to use dependency injection in module components

This commit is contained in:
Shaun Walker 2020-05-12 16:31:53 -04:00
parent 9eec0fd86b
commit 6fd0efbb73
6 changed files with 4 additions and 18 deletions

View File

@ -4,9 +4,8 @@
@namespace [Owner].[Module]s.Modules @namespace [Owner].[Module]s.Modules
@inherits ModuleBase @inherits ModuleBase
@inject I[Module]Service [Module]Service
@inject NavigationManager NavigationManager @inject NavigationManager NavigationManager
@inject HttpClient http
@inject SiteState sitestate
<table class="table table-borderless"> <table class="table table-borderless">
<tr> <tr>
@ -31,7 +30,6 @@
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit;
public override string Actions => "Add,Edit"; public override string Actions => "Add,Edit";
I[Module]Service [Module]Service;
int _id; int _id;
string _name; string _name;
string _createdby; string _createdby;
@ -43,7 +41,6 @@
{ {
try try
{ {
[Module]Service = new [Module]Service(http, sitestate);
if (PageState.Action == "Edit") if (PageState.Action == "Edit")
{ {
_id = Int32.Parse(PageState.QueryString["id"]); _id = Int32.Parse(PageState.QueryString["id"]);

View File

@ -3,9 +3,8 @@
@namespace [Owner].[Module]s.Modules @namespace [Owner].[Module]s.Modules
@inherits ModuleBase @inherits ModuleBase
@inject I[Module]Service [Module]Service
@inject NavigationManager NavigationManager @inject NavigationManager NavigationManager
@inject HttpClient http
@inject SiteState sitestate
@if (_[Module]s == null) @if (_[Module]s == null)
{ {
@ -71,14 +70,12 @@ else
<!-- The content above is for informational purposes only and can be safely removed --> <!-- The content above is for informational purposes only and can be safely removed -->
@code { @code {
I[Module]Service [Module]Service;
List<[Module]> _[Module]s; List<[Module]> _[Module]s;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
try try
{ {
[Module]Service = new [Module]Service(http, sitestate);
_[Module]s = await [Module]Service.Get[Module]sAsync(ModuleState.ModuleId); _[Module]s = await [Module]Service.Get[Module]sAsync(ModuleState.ModuleId);
} }
catch (Exception ex) catch (Exception ex)

View File

@ -10,7 +10,6 @@ namespace [Owner].[Module]s.Modules
Name = "[Module]", Name = "[Module]",
Description = "[Module]", Description = "[Module]",
Version = "1.0.0", Version = "1.0.0",
Dependencies = "[Owner].[Module]s.Shared.Oqtane",
ServerManagerType = "[ServerManagerType]", ServerManagerType = "[ServerManagerType]",
ReleaseVersions = "1.0.0" ReleaseVersions = "1.0.0"
}; };

View File

@ -4,9 +4,8 @@
@namespace [Owner].[Module]s.Modules @namespace [Owner].[Module]s.Modules
@inherits ModuleBase @inherits ModuleBase
@inject I[Module]Service [Module]Service
@inject NavigationManager NavigationManager @inject NavigationManager NavigationManager
@inject HttpClient http
@inject SiteState sitestate
<table class="table table-borderless"> <table class="table table-borderless">
<tr> <tr>
@ -31,7 +30,6 @@
public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit; public override SecurityAccessLevel SecurityAccessLevel => SecurityAccessLevel.Edit;
public override string Actions => "Add,Edit"; public override string Actions => "Add,Edit";
I[Module]Service [Module]Service;
int _id; int _id;
string _name; string _name;
string _createdby; string _createdby;
@ -43,7 +41,6 @@
{ {
try try
{ {
[Module]Service = new [Module]Service(http, sitestate);
if (PageState.Action == "Edit") if (PageState.Action == "Edit")
{ {
_id = Int32.Parse(PageState.QueryString["id"]); _id = Int32.Parse(PageState.QueryString["id"]);

View File

@ -3,9 +3,8 @@
@namespace [Owner].[Module]s.Modules @namespace [Owner].[Module]s.Modules
@inherits ModuleBase @inherits ModuleBase
@inject I[Module]Service [Module]Service
@inject NavigationManager NavigationManager @inject NavigationManager NavigationManager
@inject HttpClient http
@inject SiteState sitestate
@if (_[Module]s == null) @if (_[Module]s == null)
{ {
@ -62,14 +61,12 @@ else
<!-- The content above is for informational purposes only and can be safely removed --> <!-- The content above is for informational purposes only and can be safely removed -->
@code { @code {
I[Module]Service [Module]Service;
List<[Module]> _[Module]s; List<[Module]> _[Module]s;
protected override async Task OnInitializedAsync() protected override async Task OnInitializedAsync()
{ {
try try
{ {
[Module]Service = new [Module]Service(http, sitestate);
_[Module]s = await [Module]Service.Get[Module]sAsync(ModuleState.ModuleId); _[Module]s = await [Module]Service.Get[Module]sAsync(ModuleState.ModuleId);
} }
catch (Exception ex) catch (Exception ex)

View File

@ -10,7 +10,6 @@ namespace [Owner].[Module]s.Modules
Name = "[Module]", Name = "[Module]",
Description = "[Module]", Description = "[Module]",
Version = "1.0.0", Version = "1.0.0",
Dependencies = "[Owner].[Module]s.Module.Shared",
ServerManagerType = "[ServerManagerType]", ServerManagerType = "[ServerManagerType]",
ReleaseVersions = "1.0.0" ReleaseVersions = "1.0.0"
}; };