https://github.com/yunusefendi52/autoinjection.fody
https://github.com/yunusefendi52/autoinjection.fody
Last synced: 21 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/yunusefendi52/autoinjection.fody
- Owner: yunusefendi52
- License: mit
- Created: 2022-10-22T11:38:33.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-11-27T17:00:32.000Z (over 2 years ago)
- Last Synced: 2025-02-17T23:46:58.701Z (4 months ago)
- Language: C#
- Size: 21.5 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# AutoInjection

[](https://www.nuget.org/packages/AutoInjection.Fody)
### Installation
```xml```
Auto inject service to class with `IServiceProvider`
Register your service provider
```csharp
AutoInjection.Register(serviceProvider);
```Decorate parameter constructor
```csharp
public class MyViewModel
{
public MyViewModel([AutoInjection] IApiService apiService = null)
{
}
}
```At compile time it will inject the service provider to get the service, like
```csharp
public class MyViewModel
{
public MyViewModel([AutoInjection] IApiService apiService = null)
{
if (apiService == null)
{
apiService = AutoInjection.GetService();
}
}
}
```