Ejemplo 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()));
            }

        }
Ejemplo 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);

            //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;

            if (specifier is AsA_Host)
            {
                host = new DynamicHostController(specifier, requestedProfiles, new List<Type> { typeof(Development) }, endpointName);
            }
            else
            {
                host = new GenericHost(specifier, requestedProfiles, new List<Type> { typeof(Development), typeof(OnAzureTableStorage) }, endpointName);
            }

            return true;
        }
Ejemplo 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;
        }
        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();
        }
        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;
        }
Ejemplo 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();
        }
Ejemplo n.º 7
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(' ');

            if (specifier is AsA_Host)
            {
                host = new DynamicHostController(specifier, requestedProfiles, new[] { typeof(Development) });
            }
            else
            {
                host = new GenericHost(specifier, requestedProfiles, new[] { typeof(Development), typeof(OnAzureTableStorage) });
            }

            return true;
        }