Skip to content

Commit 261879e

Browse files
Update README.md
1 parent c7caaf5 commit 261879e

File tree

1 file changed

+35
-2
lines changed

1 file changed

+35
-2
lines changed

docs/README.md

+35-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,36 @@
1-
# Common stuff
1+
# IT.Web.Common
22

3-
_Add stuff describing the project and helpfull to contributors..._
3+
[![IT.Web.Common](https://img.shields.io/static/v1?label=IT.Web.Common&message=latest&color=blue&logo=NuGet)](https://www.nuget.org/packages/IT.Web.Common) [![IT.Web.Common.Abstractions](https://img.shields.io/static/v1?label=IT.Web.Common.Abstractions&message=latest&color=blue&logo=NuGet)](https://www.nuget.org/packages/IT.Web.Common.Abstractions)
4+
[![.NET Build](https://github.com/DefinitelyADev/IT.Web.Common/actions/workflows/build-dotnet.yml/badge.svg)](https://github.com/DefinitelyADev/IT.Web.Common/actions/workflows/build-dotnet.yml)
5+
6+
A collection of usefull tools for web applications.
7+
8+
## 1. Getting Started
9+
10+
### 1.1 Using DI
11+
12+
1. Add the [IT.Web.Common NuGet package](https://www.nuget.org/packages/IT.Web.Common) to your ASP.NET Core 6 web project.
13+
2. Register the default services to the service collection
14+
``` csharp
15+
services.AddItWebCommonServices();
16+
```
17+
3. That's it! Just use dependecy injection as you whould using the interfaces e.g.
18+
```cs
19+
var typeFinder = _host.Services.GetService<ITypeFinder>();
20+
Type[] types = typeFinder.FindClassesOfType<MyClass>().ToArray();
21+
```
22+
23+
### 1.1 Manualy
24+
25+
1. You can just add the [IT.Web.Common.Abstractions NuGet package](https://www.nuget.org/packages/IT.Web.Common.Abstractions) to your ASP.NET Core 6 web project and create your own implementations of the `ITypeFinder` and the `IWebAppFileProvider`.
26+
2. Register your implementations to the service collection. _Even though the `TryAddSingleton<>()` method is used be sure to NOT call `AddItWebCommonServices()` if you reference the `IT.Web.Common` package, unless you know what you're doing._
27+
28+
``` csharp
29+
services.TryAddSingleton<IWebAppFileProvider, MyWebAppFileProvider>();
30+
services.TryAddSingleton<ITypeFinder, MyTypeFinder>();
31+
```
32+
3. That's it! Just use dependecy injection as you whould using the interfaces e.g.
33+
```cs
34+
var typeFinder = _host.Services.GetService<ITypeFinder>();
35+
Type[] types = typeFinder.FindClassesOfType<MyClass>().ToArray();
36+
```

0 commit comments

Comments
 (0)