コード例 #1
0
        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();
        }
コード例 #2
0
        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
        }
コード例 #3
0
        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
        }
コード例 #4
0
        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);
        }
コード例 #5
0
        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);
        }
コード例 #6
0
        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);
        }
コード例 #7
0
 /// <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());
 }