webformdependencyinjection_start
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Diagnostics; | |
using System.Globalization; | |
using System.Threading; | |
namespace Microsoft.Extensions.DependencyInjection.WebForms.Sample | |
{ | |
[DebuggerDisplay("Dependency #{" + nameof(Id) + "}")] | |
public class Dependency : IDependency | |
{ | |
private static int _id; | |
public int Id { get; } | |
public Dependency() | |
{ | |
Id = Interlocked.Increment(ref _id); | |
} | |
public string GetFormattedTime() => DateTimeOffset.UtcNow.ToString("f", CultureInfo.InvariantCulture); | |
} | |
public interface IDependency | |
{ | |
int Id { get; } | |
string GetFormattedTime(); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Page Title="" Language="C#" MasterPageFile="~/Main.Master" CodeBehind="Index.aspx.cs" Inherits="Autofac.Integration.Web.Sample.Index" %> | |
<asp:Content ID="Content1" ContentPlaceHolderID="HeaderPlaceHolder" runat="server"> | |
</asp:Content> | |
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder" runat="server"> | |
<h1>Hi from Index</h1> | |
<div><%=Dependency.GetFormattedTime() %></div> | |
<div>Dependency #<%=Dependency.Id %></div> | |
</asp:Content> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Web.UI; | |
namespace Microsoft.Extensions.DependencyInjection.WebForms.Sample | |
{ | |
public partial class Index : Page | |
{ | |
protected IDependency Dependency { get; } | |
public Index(IDependency dependency) | |
{ | |
Dependency = dependency; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<%@ Master Language="C#" CodeBehind="Main.master.cs" Inherits="Autofac.Integration.Web.Sample.Main" %> | |
<!DOCTYPE html> | |
<html> | |
<head runat="server"> | |
<title></title> | |
<asp:ContentPlaceHolder ID="HeaderPlaceHolder" runat="server"> | |
</asp:ContentPlaceHolder> | |
</head> | |
<body> | |
<form id="form1" runat="server"> | |
<div> | |
<asp:ContentPlaceHolder ID="ContentPlaceHolder" runat="server"> | |
</asp:ContentPlaceHolder> | |
</div> | |
<div><%=Dependency.GetFormattedTime() %></div> | |
<div>Dependency #<%=Dependency.Id %></div> | |
</form> | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Web.UI; | |
namespace Microsoft.Extensions.DependencyInjection.WebForms.Sample | |
{ | |
public partial class Main : MasterPage | |
{ | |
protected IDependency Dependency { get; } | |
public Main(IDependency dependency) | |
{ | |
Dependency = dependency; | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment