public DefaultRegistry() { try { Scan(scanner => { scanner.Assembly("OpenCBS.GUI"); scanner.TheCallingAssembly(); scanner.WithDefaultConventions(); scanner.ConnectImplementationsToTypesClosing(typeof(ICommand <>)); scanner.AssembliesFromPath("Extensions"); scanner.LookForRegistries(); scanner.AddAllTypesOf <IMainView>(); }); } catch (System.Exception) { Scan(scanner => { scanner.Assembly("OpenCBS.GUI"); scanner.TheCallingAssembly(); scanner.WithDefaultConventions(); scanner.ConnectImplementationsToTypesClosing(typeof(ICommand <>)); scanner.LookForRegistries(); scanner.AddAllTypesOf <IMainView>(); }); } For <ITranslationService>().Singleton().Use <TranslationService>(); For <IApplicationController>().Singleton().Use <ApplicationController>(); For <ITinyMessengerHub>().Singleton().Use <TinyMessengerHub>(); For <IConnectionProvider>().Singleton().Use <ConnectionProvider>(); TypeRepository.AssertNoTypeScanningFailures(); }
public void assert_no_type_scanning_failures_happy_path() { TypeRepository.ClearAll(); TypeRepository.FindTypes(GetType().GetTypeInfo().Assembly, TypeClassification.All).Wait(); // SAMPLE: assert-no-type-scanning-failures TypeRepository.AssertNoTypeScanningFailures(); // ENDSAMPLE }
public void assert_no_type_scanning_failures_happy_path() { TypeRepository.ClearAll(); TypeRepository.FindTypes(GetType().GetAssembly(), TypeClassification.All).Wait(); #region sample_assert-no-type-scanning-failures TypeRepository.AssertNoTypeScanningFailures(); #endregion }
public static IContainer CreateContainer() { IContainer container = new Container(); container.Configure(x => { x.Policies.FillAllPropertiesOfType <IAsyncDocumentSession>(); x.Scan(s => { s.AssembliesAndExecutablesFromApplicationBaseDirectory(t => t.FullName.StartsWith("TCPIssue")); s.WithDefaultConventions(); s.LookForRegistries(); }); }); TypeRepository.AssertNoTypeScanningFailures(); return(container); }
public static Container Initialize() { var container = new Container(cfg => { cfg.Scan ( scan => { scan.AssembliesFromApplicationBaseDirectory(); scan.WithDefaultConventions(); scan.LookForRegistries(); } ); }); // Should throw an exception if any error occurs if loading dlls, which silently fail. TypeRepository.AssertNoTypeScanningFailures(); return(container); }
public static IContainer Initialize <TContainer>(params Registry[] registryTypesToInclude) where TContainer : Container, new() { Container = new TContainer(); Container.Configure(x => { foreach (Registry registryType in registryTypesToInclude) { x.IncludeRegistry(registryType); } }); string blah = Container.WhatDoIHave(); string scanned = Container.WhatDidIScan(); TypeRepository.AssertNoTypeScanningFailures(); Container.AssertConfigurationIsValid(); return(Container); }
/// <summary> /// Adds an environment check to validate all the Lamar IoC configuration, including Lamar's own /// environment checks /// </summary> public static void CheckLamarConfiguration(this IServiceCollection services) { services.CheckEnvironment("Lamar IoC Service Registrations", s => ((IContainer)s).AssertConfigurationIsValid(AssertMode.Full)); services.CheckEnvironment("Lamar IoC Type Scanning", s => TypeRepository.AssertNoTypeScanningFailures()); }