Exemplo n.º 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()));
            }
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 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());
        }
Exemplo n.º 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());
        }