public NServiceBusRoleEntrypoint() { AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException; var azureSettings = new AzureConfigurationSettings(); var requestedProfiles = GetRequestedProfiles(azureSettings); var endpointConfigurationType = GetEndpointConfigurationType(azureSettings); AssertThatEndpointConfigurationTypeHasDefaultConstructor(endpointConfigurationType); var specifier = (IConfigureThisEndpoint)Activator.CreateInstance(endpointConfigurationType); if (specifier is AsA_Host) { host = new DynamicHostController(specifier, requestedProfiles, new List<Type> { typeof(Development) }); } else { scannedAssemblies = scannedAssemblies ?? new List<Assembly>(); host = new GenericHost(specifier, requestedProfiles, new List<Type> { typeof(Development) }, scannedAssemblies.Select(s => s.ToString())); } }
static Type GetEndpointConfigurationType(AzureConfigurationSettings settings) { string endpoint; if (settings.TryGetSetting(EndpointConfigurationType, out endpoint)) { var endpointType = Type.GetType(endpoint, false); if (endpointType == null) throw new ConfigurationErrorsException( string.Format( "The 'EndpointConfigurationType' entry in the role config has specified to use the type '{0}' but that type could not be loaded.", endpoint)); return endpointType; } var endpoints = ScanAssembliesForEndpoints().ToList(); ValidateEndpoints(endpoints); return endpoints.First(); }
static Type GetEndpointConfigurationType(AzureConfigurationSettings settings) { string endpoint; if (settings.TryGetSetting(EndpointConfigurationType, out endpoint)) { var endpointType = Type.GetType(endpoint, false); if (endpointType == null) { throw new ConfigurationErrorsException( $"The 'EndpointConfigurationType' entry in the role config has specified to use the type '{endpoint}' but that type could not be loaded."); } return(endpointType); } var endpoints = ScanAssembliesForEndpoints().ToList(); ValidateEndpoints(endpoints); return(endpoints.First()); }
/// <summary> /// Initializes a new instance of <see cref="NServiceBusRoleEntrypoint" />. /// </summary> public NServiceBusRoleEntrypoint() { AppDomain.CurrentDomain.UnhandledException += CurrentDomainUnhandledException; var azureSettings = new AzureConfigurationSettings(); var endpointConfigurationType = GetEndpointConfigurationType(azureSettings); AssertThatEndpointConfigurationTypeHasDefaultConstructor(endpointConfigurationType); var specifier = Activator.CreateInstance(endpointConfigurationType); var controller = specifier as IConfigureThisHost; if (controller != null) { var controllerSettings = controller.Configure(); host = new DynamicHostController(controllerSettings); } else { host = new GenericHost((IConfigureThisEndpoint)specifier); } }