Skip to content

A lightweight and very simple service locator with dependency injection libary for C#

Notifications You must be signed in to change notification settings

pradorfl/ezservicelocator

Repository files navigation

Build status Nuget count

Introduction

You need a service locator with automated dependency injection support? No need for heavyweight IoC Containers with so many options and functionalities? This library provides exactly this!!!

Sample mapping class

public class TestAppMap : ServiceMap
{
    public override void Load()
    {
        For<INavigationRepository>().Use<NavigationCassandraRepository>();
        For<ITracker>().Use<Tracking>(new ConstructorDependency(typeof(INavigationRepository)));
    }
}

Specific mapping

ServiceLocator.Current.For<INavigationRepository>().Use<NavigationMsSqlRepository>();

Named instance mapping

ServiceLocator.Current.For<INavigationRepository>("sql").Use<NavigationMsSqlRepository>();

Self mapping

ServiceLocator.Current.Use<TestAppMap>();

Service get

ServiceLocator.Current.LoadServiceMap<TestAppMap>();

Named instance get

ServiceLocator.Current.GetService<INavigationRepository>("sql");

Upcoming updates

  • Support to named instance injection
  • Support to property injection
  • JSON mapping

About

A lightweight and very simple service locator with dependency injection libary for C#

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 4

  •  
  •  
  •  
  •  

Languages