Exemple #1
0
        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);
        }
Exemple #2
0
 private void ConfigureServices()
 {
     container.AddTransient <IWriter, ConsoleWriter>();
     container.AddTransient <IReader, ConsoleReader>();
     container.AddSingleton <ILogger, Logger.Logger>((Logger.Logger)GetLogger());
 }
Exemple #3
0
 public static void Register(IocContainer iocContainer)
 {
     iocContainer.AddSingleton <IImmoXXLWebClient, ImmoXXLWebClient>();
     iocContainer.AddSingleton <IImmoXXLPropertyConverter, ImmoXXLPropertyConverter>();
     iocContainer.AddSingleton <IPropertyProvider, ImmoXXLClient>();
 }