Created
December 31, 2012 15:59
-
-
Save gshackles/4420870 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class TinyIoCProvider : IMvxIoCProvider | |
{ | |
private readonly TinyIoCContainer _container; | |
public TinyIoCProvider() | |
{ | |
_container = new TinyIoCContainer(); | |
} | |
public bool SupportsService<T>() where T : class | |
{ | |
return _container.CanResolve<T>(); | |
} | |
public T GetService<T>() where T : class | |
{ | |
return _container.Resolve<T>(); | |
} | |
public bool TryGetService<T>(out T service) where T : class | |
{ | |
return _container.TryResolve(out service); | |
} | |
public void RegisterServiceType<TFrom, TTo>() where TFrom : class where TTo : class, TFrom | |
{ | |
_container.Register<TFrom, TTo>(); | |
} | |
public void RegisterServiceInstance<TInterface>(TInterface theObject) where TInterface : class | |
{ | |
_container.Register<TInterface>(theObject); | |
} | |
public void RegisterServiceInstance<TInterface>(Func<TInterface> theConstructor) where TInterface : class | |
{ | |
_container.Register<TInterface>((c, p) => theConstructor()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment