Example #1
0
        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()));
            }
        }
Example #2
0
        public override bool OnStart()
        {
            var azureSettings           = new AzureConfigurationSettings();
            var requestedProfileSetting = azureSettings.GetSetting(ProfileSetting);

            var endpointConfigurationType = GetEndpointConfigurationType(azureSettings);

            AssertThatEndpointConfigurationTypeHasDefaultConstructor(endpointConfigurationType);

            var specifier         = (IConfigureThisEndpoint)Activator.CreateInstance(endpointConfigurationType);
            var requestedProfiles = requestedProfileSetting.Split(' ');

            requestedProfiles = AddProfilesFromConfiguration(requestedProfiles);

            if (specifier is AsA_Host)
            {
                host = new DynamicHostController(specifier, requestedProfiles, new[] { typeof(Development) });
            }
            else
            {
                //var endpointName = "Put somethingt smart here Yves"; // wonder if I live up to the expectations :)
                var endpointName = RoleEnvironment.IsAvailable ? RoleEnvironment.CurrentRoleInstance.Role.Name : GetType().Name;
                host = new GenericHost(specifier, requestedProfiles, new[] { typeof(Development), typeof(OnAzureTableStorage) }, endpointName);
            }

            return(true);
        }
Example #3
0
        public override bool OnStart()
        {
            var azureSettings     = new AzureConfigurationSettings();
            var requestedProfiles = azureSettings.GetSetting(ProfileSetting);

            var endpointConfigurationType = GetEndpointConfigurationType(azureSettings);

            AssertThatEndpointConfigurationTypeHasDefaultConstructor(endpointConfigurationType);

            var specifier = (IConfigureThisEndpoint)Activator.CreateInstance(endpointConfigurationType);

            genericHost = new GenericHost(specifier, requestedProfiles.Split(' '), null);

            return(true);
        }
Example #4
0
        private static GenericHost StartHost()
        {
            Configure.WithWeb();

            var azureSettings     = new AzureConfigurationSettings();
            var requestedProfiles = azureSettings.GetSetting(ProfileSetting);

            var endpointConfigurationType = GetEndpointConfigurationType(azureSettings);

            AssertThatEndpointConfigurationTypeHasDefaultConstructor(endpointConfigurationType);

            var specifier = (IConfigureThisEndpoint)Activator.CreateInstance(endpointConfigurationType);

            var genericHost = new GenericHost(specifier, requestedProfiles.Split(' '), null);

            genericHost.Start();

            return(genericHost);
        }
Example #5
0
        private static Type GetEndpointConfigurationType(AzureConfigurationSettings settings)
        {
            string endpoint = settings.GetSetting("EndpointConfigurationType");

            if (!String.IsNullOrEmpty(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);
            }

            IEnumerable <Type> endpoints = ScanAssembliesForEndpoints();

            ValidateEndpoints(endpoints);

            return(endpoints.First());
        }
Example #6
0
        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());
        }