public void Can_Resolve_Singleton() { var ioc = new IocContainer(); ioc.AddSingleton <ILogger, Logger>(); ioc.AddSingleton(typeof(IRepository <>), typeof(Repository <>)); var repo = ioc.Resolve <IRepository <Customer> >(); var repo2 = ioc.Resolve <IRepository <Customer> >(); Assert.AreEqual(typeof(Repository <Customer>), repo.GetType()); Assert.AreSame(repo, repo2); }
private void ConfigureServices() { container.AddTransient <IWriter, ConsoleWriter>(); container.AddTransient <IReader, ConsoleReader>(); container.AddSingleton <ILogger, Logger.Logger>((Logger.Logger)GetLogger()); }
public static void Register(IocContainer iocContainer) { iocContainer.AddSingleton <IImmoXXLWebClient, ImmoXXLWebClient>(); iocContainer.AddSingleton <IImmoXXLPropertyConverter, ImmoXXLPropertyConverter>(); iocContainer.AddSingleton <IPropertyProvider, ImmoXXLClient>(); }