Skip to content

Commit cfc49dc

Browse files
Release 1.2.0 (#8) - Add the support of the ActivatorUtilitiesConstructor attribute in the ASP .NET controls.
* Add the support of the ActivatorUtilitiesConstructor attribute in the ASP .NET controls. * Fix the bug #7 with parameter less constructors in the ActivatorUtilitiesConstructorTypeAdapter.
1 parent 07136d7 commit cfc49dc

16 files changed

+955
-24
lines changed

AspNet.WebForms.DependencyInjection.IntegrationTests/About.aspx.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,14 @@ namespace PosInformatique.AspNet.WebForms.DependencyInjection.IntegrationTests
99
{
1010
public partial class About : Page
1111
{
12+
static About()
13+
{
14+
}
15+
16+
public About()
17+
{
18+
}
19+
1220
protected void Page_Load(object sender, EventArgs e)
1321
{
1422

AspNet.WebForms.DependencyInjection.IntegrationTests/AspNet.WebForms.DependencyInjection.IntegrationTests.csproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
<Content Include="Scripts\WebForms\WebParts.js" />
113113
<Content Include="Scripts\WebForms\WebUIValidation.js" />
114114
<Content Include="Site.Master" />
115+
<Content Include="UserControlWithDependency.ascx" />
115116
<Content Include="ViewSwitcher.ascx" />
116117
<Content Include="Web.config" />
117118
<Content Include="Bundle.config" />
@@ -165,6 +166,13 @@
165166
<Compile Include="Site.Mobile.Master.designer.cs">
166167
<DependentUpon>Site.Mobile.Master</DependentUpon>
167168
</Compile>
169+
<Compile Include="UserControlWithDependency.ascx.cs">
170+
<DependentUpon>UserControlWithDependency.ascx</DependentUpon>
171+
<SubType>ASPXCodeBehind</SubType>
172+
</Compile>
173+
<Compile Include="UserControlWithDependency.ascx.designer.cs">
174+
<DependentUpon>UserControlWithDependency.ascx</DependentUpon>
175+
</Compile>
168176
<Compile Include="ViewSwitcher.ascx.cs">
169177
<DependentUpon>ViewSwitcher.ascx</DependentUpon>
170178
<SubType>ASPXCodeBehind</SubType>

AspNet.WebForms.DependencyInjection.IntegrationTests/Default.aspx

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
<%@ Page Title="Home Page" Language="C#" MasterPageFile="~/Site.Master" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="PosInformatique.AspNet.WebForms.DependencyInjection.IntegrationTests._Default" %>
22
<%@ Import Namespace="PosInformatique.AspNet.WebForms.DependencyInjection.IntegrationTests" %>
3+
<%@ Register Src="~/UserControlWithDependency.ascx" TagPrefix="uc1" TagName="UserControlWithDependency" %>
4+
35

46
<asp:Content ID="BodyContent" ContentPlaceHolderID="MainContent" runat="server">
57

@@ -13,8 +15,8 @@
1315
<asp:GridView runat="server" ID="doggoList" ItemType="PosInformatique.AspNet.WebForms.DependencyInjection.IntegrationTests.Dog" AutoGenerateColumns="false">
1416
<Columns>
1517
<asp:BoundField DataField="Name" />
16-
<asp:BoundField DataField="TatooNumber" />
17-
</Columns>
18+
<asp:BoundField DataField="TatooNumber" />
19+
</Columns>
1820
</asp:GridView>
1921

2022
<p>
@@ -31,6 +33,8 @@
3133

3234
URL from HttpRequest injected: <asp:Label runat="server" ID="urlFromHttpRequest" />
3335

36+
<p>User Control with dependency:</p>
37+
<uc1:UserControlWithDependency runat="server" id="UserControlWithDependency" />
3438
<!-- End the test -->
3539
<div class="row">
3640
<div class="col-md-4">

AspNet.WebForms.DependencyInjection.IntegrationTests/Default.aspx.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
using System.Web;
55
using System.Web.UI;
66
using System.Web.UI.WebControls;
7+
using Microsoft.Extensions.DependencyInjection;
78

89
namespace PosInformatique.AspNet.WebForms.DependencyInjection.IntegrationTests
910
{
@@ -13,12 +14,17 @@ public partial class _Default : Page
1314

1415
private readonly HttpRequest httpRequest;
1516

17+
[ActivatorUtilitiesConstructor]
1618
public _Default(IDogManager dogManager, HttpRequest httpRequest)
1719
{
1820
this.dogManager = dogManager;
1921
this.httpRequest = httpRequest;
2022
}
2123

24+
public _Default()
25+
{
26+
}
27+
2228
protected void Page_Load(object sender, EventArgs e)
2329
{
2430
this.doggoList.DataSource = this.dogManager.GetDogs();

AspNet.WebForms.DependencyInjection.IntegrationTests/Default.aspx.designer.cs

Lines changed: 17 additions & 6 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="UserControlWithDependency.ascx.cs" Inherits="PosInformatique.AspNet.WebForms.DependencyInjection.IntegrationTests.UserControlWithDependency" %>
2+
3+
<p>Doggo from the UserControlWithDependency user control</p>
4+
<!-- Use the DogManager/DogRepository -->
5+
<asp:GridView runat="server" ID="doggoList" ItemType="PosInformatique.AspNet.WebForms.DependencyInjection.IntegrationTests.Dog" AutoGenerateColumns="false">
6+
<Columns>
7+
<asp:BoundField DataField="Name" />
8+
<asp:BoundField DataField="TatooNumber" />
9+
</Columns>
10+
</asp:GridView>
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
using System;
2+
using System.CodeDom;
3+
using System.Collections.Generic;
4+
using System.Linq;
5+
using System.Web;
6+
using System.Web.UI;
7+
using System.Web.UI.WebControls;
8+
using Microsoft.Extensions.DependencyInjection;
9+
10+
namespace PosInformatique.AspNet.WebForms.DependencyInjection.IntegrationTests
11+
{
12+
public partial class UserControlWithDependency : System.Web.UI.UserControl
13+
{
14+
private readonly IDogManager dogManager;
15+
16+
[ActivatorUtilitiesConstructor]
17+
public UserControlWithDependency(IDogManager dogManager)
18+
{
19+
this.dogManager = dogManager;
20+
}
21+
22+
public UserControlWithDependency(IDogManager dogManager, IDogRepository dogRepository)
23+
{
24+
throw new InvalidOperationException("Must not be called");
25+
}
26+
27+
public UserControlWithDependency()
28+
{
29+
throw new InvalidOperationException("Must not be called");
30+
}
31+
32+
protected void Page_Load(object sender, EventArgs e)
33+
{
34+
this.doggoList.DataSource = this.dogManager.GetDogs();
35+
this.doggoList.DataBind();
36+
}
37+
}
38+
}

AspNet.WebForms.DependencyInjection.IntegrationTests/UserControlWithDependency.ascx.designer.cs

Lines changed: 26 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)