Esempio n. 1
0
        public static Task <IStartableEndpoint> CreateWithInternallyManagedContainer(EndpointConfiguration endpointConfiguration)
        {
            FinalizeConfiguration(endpointConfiguration);

            endpointConfiguration.ContainerComponent.InitializeWithInternallyManagedContainer();

            var creator = new EndpointCreator(endpointConfiguration.Settings, endpointConfiguration.ContainerComponent, endpointConfiguration.PipelineComponent);

            creator.Initialize();

            return(creator.CreateStartableEndpoint());
        }
Esempio n. 2
0
        public static Task <IStartableEndpoint> CreateWithInternallyManagedContainer(EndpointConfiguration endpointConfiguration)
        {
            var settings = endpointConfiguration.Settings;

            var assemblyScanningComponent = AssemblyScanningComponent.Initialize(settings.Get <AssemblyScanningComponent.Configuration>(), settings);

            FinalizeConfiguration(endpointConfiguration, assemblyScanningComponent.AvailableTypes);

            var hostingSettting   = settings.Get <HostingComponent.Settings>();
            var useDefaultBuilder = hostingSettting.CustomObjectBuilder == null;
            var container         = useDefaultBuilder ? new LightInjectObjectBuilder() : hostingSettting.CustomObjectBuilder;

            var commonObjectBuilder = new CommonObjectBuilder(container);

            IConfigureComponents internalContainer = commonObjectBuilder;
            IBuilder             internalBuilder   = commonObjectBuilder;

            //for backwards compatibility we need to make the IBuilder available in the container
            internalContainer.ConfigureComponent(_ => internalBuilder, DependencyLifecycle.SingleInstance);

            var hostingConfiguration = HostingComponent.PrepareConfiguration(settings.Get <HostingComponent.Settings>(), assemblyScanningComponent, internalContainer);

            if (useDefaultBuilder)
            {
                hostingConfiguration.AddStartupDiagnosticsSection("Container", new
                {
                    Type = "internal"
                });
            }
            else
            {
                var containerType = internalContainer.GetType();

                hostingConfiguration.AddStartupDiagnosticsSection("Container", new
                {
                    Type    = containerType.FullName,
                    Version = FileVersionRetriever.GetFileVersion(containerType)
                });
            }

            var endpointCreator = new EndpointCreator(settings, hostingConfiguration);

            endpointCreator.Initialize();

            var hostingComponent = HostingComponent.Initialize(hostingConfiguration, internalBuilder);

            return(endpointCreator.CreateStartableEndpoint(internalBuilder, hostingComponent));
        }