public void StartupTest() { var assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList(); _serviceLocator.RegisterInstance(assemblies); var typeCatalog = new AppDomainTypeCatalog(assemblies); _serviceLocator.Register<ITypeCatalog>(() => typeCatalog); var localTypeCatalog = _serviceLocator.Resolve<ITypeCatalog>(); var localAssembliesInstance = _serviceLocator.Resolve<List<Assembly>>(); Assert.IsInstanceOfType(localTypeCatalog, typeof (AppDomainTypeCatalog)); Assert.AreEqual(typeCatalog, localTypeCatalog); Assert.IsTrue(typeCatalog.Equals(localTypeCatalog)); Assert.IsTrue(ReferenceEquals(typeCatalog, localTypeCatalog)); }
public void StartupTest() { var assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList(); _serviceLocator.RegisterInstance(assemblies); ITypeCatalog typeCatalog = new AppDomainTypeCatalog(assemblies); _serviceLocator.Register(() => typeCatalog); var localTypeCatalog = _serviceLocator.Resolve <ITypeCatalog>(); var localAssembliesInstance = _serviceLocator.Resolve <List <Assembly> >(); Assert.IsInstanceOfType(localTypeCatalog, typeof(AppDomainTypeCatalog)); Assert.AreEqual(typeCatalog, localTypeCatalog); Assert.IsTrue(typeCatalog.Equals(localTypeCatalog)); Assert.IsTrue(ReferenceEquals(typeCatalog, localTypeCatalog)); }
public static ITypeCatalog GetTypeCatalog(IServiceLocator serviceLocator) { var typeCatalog = serviceLocator.Resolve<ITypeCatalog>(); if (typeCatalog != null) { return typeCatalog; } var assemblies = serviceLocator.Resolve<List<Assembly>>(); if (assemblies == null || assemblies.Count < 1) { assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList(); } serviceLocator.RegisterInstance(assemblies); typeCatalog = new AppDomainTypeCatalog(assemblies); serviceLocator.Register(() => typeCatalog); return typeCatalog; }
public static ITypeCatalog GetTypeCatalog(IServiceLocator serviceLocator) { var typeCatalog = serviceLocator.Resolve <ITypeCatalog>(); if (typeCatalog != null) { return(typeCatalog); } var assemblies = serviceLocator.Resolve <List <Assembly> >(); if (assemblies == null || assemblies.Count < 1) { assemblies = AppDomain.CurrentDomain.GetAssemblies().ToList(); } serviceLocator.RegisterInstance(assemblies); typeCatalog = new AppDomainTypeCatalog(assemblies); serviceLocator.Register(() => typeCatalog); return(typeCatalog); }