Skip to content
This repository was archived by the owner on Aug 27, 2020. It is now read-only.

IDependencyService

Mark Smith edited this page Sep 2, 2016 · 4 revisions

IDependencyService

The IDependencyService interface is a simple representation of a Service Locator.

Methods

  • Get<T> : returns a T object.
  • Register<T> : registers a T` object.
  • Register<T,TImpl> : registers a TImplobject as aT` abstraction.
/// <summary>
/// Interface to wrap a ServiceLocator
/// </summary>
public interface IDependencyService
{
   /// <summary>
   /// Register a specific type as an abstraction
   /// </summary>
   /// <typeparam name="T">The class to register</typeparam>
   void Register<T> () where T : class, new();

   /// <summary>
   /// Register a specific abstraction associated to a type.
   /// </summary>
   /// <typeparam name="T">The abstraction</typeparam>
   /// <typeparam name="TImpl">The implementation</typeparam>
   void Register<T, TImpl> () where T : class where TImpl : class, T, new();
  
   /// <summary>
   /// Retrieve a specific implementation from the locator.
   /// </summary>
   /// <typeparam name="T">Type to look for</typeparam>
   T Get<T>() where T : class;
}
Clone this wiki locally