Skip to content

Commit d0e9acb

Browse files
Fix the README file
1 parent eb235ec commit d0e9acb

File tree

2 files changed

+72
-1
lines changed

2 files changed

+72
-1
lines changed

PosInformatique.AspNet.WebForms.DependencyInjection.sln

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,14 @@ Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.WebForms.DependencyI
77
EndProject
88
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.WebForms.DependencyInjection", "AspNet.WebForms.DependencyInjection\AspNet.WebForms.DependencyInjection.csproj", "{CAC03029-4557-4333-AD25-1BC2F58E56CB}"
99
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNet.WebForms.DependencyInjection.Tests", "AspNet.WebForms.DependencyInjection.Tests\AspNet.WebForms.DependencyInjection.Tests.csproj", "{7A12C3D4-C50E-414E-9BF2-14918821F088}"
10+
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "AspNet.WebForms.DependencyInjection.Tests", "AspNet.WebForms.DependencyInjection.Tests\AspNet.WebForms.DependencyInjection.Tests.csproj", "{7A12C3D4-C50E-414E-9BF2-14918821F088}"
11+
EndProject
12+
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Solution Items", "Solution Items", "{B82864CE-314D-4B4E-BA88-54CC5896FE24}"
13+
ProjectSection(SolutionItems) = preProject
14+
.gitignore = .gitignore
15+
README.md = README.md
16+
stylecop.json = stylecop.json
17+
EndProjectSection
1118
EndProject
1219
Global
1320
GlobalSection(SolutionConfigurationPlatforms) = preSolution

README.md

Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,66 @@
11
# PosInformatique.AspNet.WebForms.DependencyInjection
22
PosInformatique.AspNet.WebForms.DependencyInjection is a library to add the IoC container support of Microsoft.Extensions.DependencyInjection for ASP .NET Web Forms
3+
4+
## Installing from NuGet
5+
The **PosInformatique.AspNet.WebForms.DependencyInjection** is available directly on the
6+
[NuGet](https://www.nuget.org/packages/PosInformatique.AspNet.WebForms.DependencyInjection/) official website.
7+
To download and install the library to your Visual Studio project using the following NuGet command line
8+
```
9+
Install-Package PosInformatique.AspNet.WebForms.DependencyInjection
10+
```
11+
12+
## Setting up
13+
After adding the **PosInformatique.AspNet.WebForms.DependencyInjection** package on your ASP .NET
14+
WebForms project call the `AddServiceCollection` the following lines in the constructor of your `HttpApplication` class in the
15+
`Global.asax.cs` code behind:
16+
```csharp
17+
public class Global : HttpApplication
18+
{
19+
public Global()
20+
{
21+
ServicesConfig.RegisterServices(this.AddServiceCollection());
22+
}
23+
24+
void Application_Start(object sender, EventArgs e)
25+
{
26+
// Code that runs on application startup
27+
RouteConfig.RegisterRoutes(RouteTable.Routes);
28+
BundleConfig.RegisterBundles(BundleTable.Bundles);
29+
}
30+
}
31+
```
32+
33+
In the `App_Start` folder add a new static class called `ServicesConfig` which allows to register
34+
the services using the `Microsoft.Extensions.DependencyInjection.ServiceCollection`:
35+
```csharp
36+
namespace PosInformatique.AspNet.WebForms.DependencyInjection.IntegrationTests
37+
{
38+
using System;
39+
using System.Collections.Generic;
40+
using System.Collections.ObjectModel;
41+
using System.Linq;
42+
using Microsoft.Extensions.DependencyInjection;
43+
44+
public static class ServicesConfig
45+
{
46+
public static void RegisterServices(ServiceCollection serviceCollection)
47+
{
48+
serviceCollection.AddSingleton<IDogRepository, DogRepository>();
49+
serviceCollection.AddTransient<IDogManager, DogManager>();
50+
}
51+
}
52+
}
53+
```
54+
You can register services with a *Transient* or *Singleton* scope. Unlike to ASP .NET Core,
55+
**PosInformatique.AspNet.WebForms.DependencyInjection** does not support *Scoped* scope services
56+
which exists during the HTTP request lifetime.
57+
58+
## Contributions
59+
Do not hesitate to clone my code and submit some changes...
60+
It is a open source project, so everyone is welcome to improve this library...
61+
By the way, I am french... So maybe you will remarks that my english is not really fluent...
62+
So do not hesitate to fix my resources strings or my documentation... Merci !
63+
64+
## Thanks
65+
I want to thank the [DiliTrust](https://www.dilitrust.com/) company to test and gave me their
66+
feedback of this library for their ASP .NET WebForms applications.

0 commit comments

Comments
 (0)