Skip to content

Instantly share code, notes, and snippets.

@gshackles
Created December 31, 2012 15:59
Show Gist options
  • Save gshackles/4420870 to your computer and use it in GitHub Desktop.
Save gshackles/4420870 to your computer and use it in GitHub Desktop.
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