Exemplo n.º 1
0
        /// <summary>
        /// This is the entry point of the service host process.
        /// </summary>
        private static void Main()
        {
            try
            {
                IContainerBuilder containerBuilder = new DefaultContainerBuilder();
                containerBuilder.Build();

                ServiceRuntime.RegisterServiceAsync("DiscoveryServiceType", ServiceFactory).GetAwaiter().GetResult();

                ServiceEventSource.Current.ServiceTypeRegistered(Process.GetCurrentProcess().Id, typeof(DiscoveryService).Name);

                // Prevents this host process from terminating so services keeps running.
                Thread.Sleep(Timeout.Infinite);
            }
            catch (Exception e)
            {
                ServiceEventSource.Current.ServiceHostInitializationFailed(e.ToString());
                throw;
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// Configures the dependency resolver for Cofoundry and
        /// registers all the services, repositories and modules setup for auto-registration.
        /// </summary>
        public static IMvcBuilder AddCofoundry(
            this IMvcBuilder mvcBuilder,
            IConfiguration configuration,
            Action <AddCofoundryStartupConfiguration> configBuilder = null
            )
        {
            var cofoundryConfig = new AddCofoundryStartupConfiguration();

            configBuilder?.Invoke(cofoundryConfig);

            AddAdditionalTypes(mvcBuilder);
            DiscoverAdditionalApplicationParts(mvcBuilder, cofoundryConfig);

            var typesProvider = new DiscoveredTypesProvider(mvcBuilder.PartManager);
            var builder       = new DefaultContainerBuilder(mvcBuilder.Services, typesProvider, configuration);

            builder.Build();

            RunAdditionalConfiguration(mvcBuilder);

            return(mvcBuilder);
        }