Skip to content

RoverCore/Serviced

 
 

Repository files navigation

What is Serviced

Serviced is a simple lightweight library that handles service registrations for you.

Author

This code was originally written by Georgi Stoyanov and forked for the RoverCore project. Many thanks to Georgi for offering his repository under the MIT license as we are doing with all RoverCore projects as well. Check out his original project here

How to setup

// Register ( how ironic ) Serviced in your Startup.cs
services.AddServiced(typeof(Startup).Assembly);

Pass as parameter the assemblies where your services are located. You can pass multiple assemblies or a single one.

How to use

There are 3 major interfaces

  • ITransient
  • IScoped
  • ISingleton

All of them have generic and non-generic version.

Example: Lets say you want to register a service named "HomeService" with an interface "IHomeService" as transient service.

class HomeService: IHomeService, ITransient<IHomeService>

The above interface basically saves you from this syntax in Startup.cs

services.AddTransient<IHomeService,HomeService>();

Another example is, lets say you want to register "HomeService" without an interface. Simply inherit the ITransient interface.

class HomeService: ITransient

Below is the Startup.cs equivalent.

services.AddTransient<HomeService>();

About

Serviced is a simple lightweight library that handles service registrations for you.

Resources

License

Stars

Watchers

Forks

Packages

 
 
 

Contributors

Languages

  • C# 100.0%