/// <summary>
        /// Initializes a new instance of the <see cref="JobHostConfiguration"/> class, using the
        /// specified connection string for both reading and writing data as well as Dashboard logging.
        /// </summary>
        /// <param name="dashboardAndStorageConnectionString">The Azure Storage connection string to use.
        /// </param>
        public JobHostConfiguration(string dashboardAndStorageConnectionString)
        {
            if (!string.IsNullOrEmpty(dashboardAndStorageConnectionString))
            {
                _storageAccountProvider = new DefaultStorageAccountProvider(this, dashboardAndStorageConnectionString);
            }
            else
            {
                _storageAccountProvider = new DefaultStorageAccountProvider(this);
            }

            Singleton = new SingletonConfiguration();

            // add our built in services here
            IExtensionRegistry extensions  = new DefaultExtensionRegistry();
            ITypeLocator       typeLocator = new DefaultTypeLocator(ConsoleProvider.Out, extensions);

            AddService <IExtensionRegistry>(extensions);
            AddService <StorageClientFactory>(new StorageClientFactory());
            AddService <INameResolver>(new DefaultNameResolver());
            AddService <IJobActivator>(DefaultJobActivator.Instance);
            AddService <ITypeLocator>(typeLocator);

            string value = ConfigurationUtility.GetSettingFromConfigOrEnvironment(Constants.EnvironmentSettingName);

            IsDevelopment = string.Compare(Constants.DevelopmentEnvironmentValue, value, StringComparison.OrdinalIgnoreCase) == 0;
        }
Esempio n. 2
0
        public void IsJobClass_IfContainsGenericParameters_ReturnsFalse()
        {
            Type type = typeof(GenericClass <>);

            // Act
            bool result = DefaultTypeLocator.IsJobClass(type);

            // Assert
            Assert.False(result);
        }
Esempio n. 3
0
        public void IsJobClass_IfNormalPublicClass_ReturnsTrue()
        {
            Type type = typeof(PublicClass);

            // Act
            bool result = DefaultTypeLocator.IsJobClass(type);

            // Assert
            Assert.True(result);
        }
Esempio n. 4
0
        public void IsJobClass_IfPrivate_ReturnsFalse()
        {
            Type type = typeof(PrivateClass);

            // Act
            bool result = DefaultTypeLocator.IsJobClass(type);

            // Assert
            Assert.False(result);
        }
Esempio n. 5
0
        public void IsJobClass_IfNestedPublic_ReturnsFalse()
        {
            Type type = typeof(NestedPublicClass);

            // Act
            bool result = DefaultTypeLocator.IsJobClass(type);

            // Assert
            Assert.False(result);
        }
Esempio n. 6
0
        public void IsJobClass_IfAbstract_ReturnsFalse()
        {
            Type type = typeof(AbstractClass);

            // Act
            bool result = DefaultTypeLocator.IsJobClass(type);

            // Assert
            Assert.False(result);
        }
Esempio n. 7
0
        public void IsJobClass_IfInterface_ReturnsFalse()
        {
            Type type = typeof(PublicInterface);

            // Act
            bool result = DefaultTypeLocator.IsJobClass(type);

            // Assert
            Assert.False(result);
        }
Esempio n. 8
0
        public void IsJobClass_IfValueType_ReturnsFalse()
        {
            Type type = typeof(PublicStruct);

            // Act
            bool result = DefaultTypeLocator.IsJobClass(type);

            // Assert
            Assert.False(result);
        }
Esempio n. 9
0
        public void IsJobClass_IfNull_ReturnsFalse()
        {
            Type type = null;

            // Act
            bool result = DefaultTypeLocator.IsJobClass(type);

            // Assert
            Assert.False(result);
        }
Esempio n. 10
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JobHostConfiguration"/> class, using the
        /// specified connection string for both reading and writing data as well as Dashboard logging.
        /// </summary>
        /// <param name="dashboardAndStorageConnectionString">The Azure Storage connection string to use.
        /// <param name="configuration">A configuration object that will be used as the source of application settings.</param>
        /// </param>
        public JobHostConfiguration(string dashboardAndStorageConnectionString, IConfiguration configuration)
        {
            if (configuration != null)
            {
                ConfigurationUtility.SetConfigurationFactory(() => configuration);
            }

            if (!string.IsNullOrEmpty(dashboardAndStorageConnectionString))
            {
                _storageAccountProvider = new DefaultStorageAccountProvider(this, dashboardAndStorageConnectionString);
            }
            else
            {
                _storageAccountProvider = new DefaultStorageAccountProvider(this);
            }

            var sasBlobContainer = _storageAccountProvider.InternalSasStorage;

            if (sasBlobContainer != null)
            {
                var uri          = new Uri(sasBlobContainer);
                var sdkContainer = new CloudBlobContainer(uri);

                this.InternalStorageConfiguration = new JobHostInternalStorageConfiguration
                {
                    InternalContainer = sdkContainer
                };
            }

            Singleton  = new SingletonConfiguration();
            Aggregator = new FunctionResultAggregatorConfiguration();

            // add our built in services here
            IExtensionRegistry       extensions       = new DefaultExtensionRegistry();
            ITypeLocator             typeLocator      = new DefaultTypeLocator(ConsoleProvider.Out, extensions);
            IConverterManager        converterManager = new ConverterManager();
            IWebJobsExceptionHandler exceptionHandler = new WebJobsExceptionHandler();

            AddService <IQueueConfiguration>(_queueConfiguration);
            AddService <IConsoleProvider>(ConsoleProvider);
            AddService <ILoggerFactory>(new LoggerFactory());
            AddService <IStorageAccountProvider>(_storageAccountProvider);
            AddService <IExtensionRegistry>(extensions);
            AddService <StorageClientFactory>(new StorageClientFactory());
            AddService <INameResolver>(new DefaultNameResolver());
            AddService <IJobActivator>(DefaultJobActivator.Instance);
            AddService <ITypeLocator>(typeLocator);
            AddService <IConverterManager>(converterManager);
            AddService <IWebJobsExceptionHandler>(exceptionHandler);
            AddService <IFunctionResultAggregatorFactory>(new FunctionResultAggregatorFactory());

            string value = ConfigurationUtility.GetSetting(Host.Constants.EnvironmentSettingName);

            IsDevelopment = string.Compare(Host.Constants.DevelopmentEnvironmentValue, value, StringComparison.OrdinalIgnoreCase) == 0;
        }
Esempio n. 11
0
        public Task <JobHostContext> CreateAndLogHostStartedAsync(JobHost host, CancellationToken shutdownToken, CancellationToken cancellationToken)
        {
            ITypeLocator         typeLocator  = new DefaultTypeLocator(new StringWriter(), new DefaultExtensionRegistry());
            INameResolver        nameResolver = new RandomNameResolver();
            JobHostConfiguration config       = new JobHostConfiguration
            {
                NameResolver = nameResolver,
                TypeLocator  = typeLocator
            };

            return(JobHostContextFactory.CreateAndLogHostStartedAsync(
                       host, StorageAccountProvider, Queues, typeLocator, DefaultJobActivator.Instance, nameResolver,
                       new NullConsoleProvider(), new JobHostConfiguration(), shutdownToken, cancellationToken, new WebJobsExceptionHandler(),
                       functionIndexProvider: FunctionIndexProvider, singletonManager: SingletonManager, hostIdProvider: HostIdProvider));
        }
        public Task <JobHostContext> CreateAndLogHostStartedAsync(CancellationToken shutdownToken, CancellationToken cancellationToken)
        {
            ITypeLocator         typeLocator  = new DefaultTypeLocator(new StringWriter());
            INameResolver        nameResolver = new RandomNameResolver();
            JobHostConfiguration config       = new JobHostConfiguration
            {
                NameResolver = nameResolver,
                TypeLocator  = typeLocator
            };

            return(JobHostContextFactory.CreateAndLogHostStartedAsync(
                       StorageAccountProvider, Queues, typeLocator, DefaultJobActivator.Instance, nameResolver,
                       new NullConsoleProvider(), new JobHostConfiguration(), shutdownToken, cancellationToken,
                       functionIndexProvider: FunctionIndexProvider));
        }
        public Task <JobHostContext> CreateAndLogHostStartedAsync(CancellationToken shutdownToken, CancellationToken cancellationToken)
        {
            ITypeLocator         typeLocator  = new DefaultTypeLocator(new StringWriter());
            INameResolver        nameResolver = new RandomNameResolver();
            JobHostConfiguration config       = new JobHostConfiguration
            {
                NameResolver = nameResolver,
                TypeLocator  = typeLocator
            };

            return(JobHostContextFactory.CreateAndLogHostStartedAsync(
                       StorageAccountProvider, config.Queues, typeLocator, DefaultJobActivator.Instance, nameResolver,
                       new NullConsoleProvider(), new JobHostConfiguration(), shutdownToken, cancellationToken,
                       new FixedHostIdProvider(Guid.NewGuid().ToString("N")),
                       null, new EmptyFunctionIndexProvider(),
                       null, new NullHostInstanceLoggerProvider(), new NullFunctionInstanceLoggerProvider(), new NullFunctionOutputLoggerProvider()));
        }
        /// <summary>
        /// Initializes a new instance of the <see cref="JobHostConfiguration"/> class, using the
        /// specified connection string for both reading and writing data as well as Dashboard logging.
        /// </summary>
        /// <param name="dashboardAndStorageConnectionString">The Azure Storage connection string to use.
        /// </param>
        public JobHostConfiguration(string dashboardAndStorageConnectionString)
        {
            if (!string.IsNullOrEmpty(dashboardAndStorageConnectionString))
            {
                _storageAccountProvider = new DefaultStorageAccountProvider(this, dashboardAndStorageConnectionString);
            }
            else
            {
                _storageAccountProvider = new DefaultStorageAccountProvider(this);
            }

            Singleton = new SingletonConfiguration();

            // add our built in services here
            IExtensionRegistry extensions  = new DefaultExtensionRegistry();
            ITypeLocator       typeLocator = new DefaultTypeLocator(ConsoleProvider.Out, extensions);

            AddService <IExtensionRegistry>(extensions);
            AddService <StorageClientFactory>(new StorageClientFactory());
            AddService <INameResolver>(new DefaultNameResolver());
            AddService <IJobActivator>(DefaultJobActivator.Instance);
            AddService <ITypeLocator>(typeLocator);
        }
Esempio n. 15
0
        /// <summary>
        /// Initializes a new instance of the <see cref="JobHostConfiguration"/> class, using the
        /// specified connection string for both reading and writing data as well as Dashboard logging.
        /// </summary>
        /// <param name="dashboardAndStorageConnectionString">The Azure Storage connection string to use.
        /// </param>
        public JobHostConfiguration(string dashboardAndStorageConnectionString)
        {
            if (!string.IsNullOrEmpty(dashboardAndStorageConnectionString))
            {
                _storageAccountProvider = new DefaultStorageAccountProvider(this, dashboardAndStorageConnectionString);
            }
            else
            {
                _storageAccountProvider = new DefaultStorageAccountProvider(this);
            }

            Singleton  = new SingletonConfiguration();
            Aggregator = new FunctionResultAggregatorConfiguration();

            // add our built in services here
            _tooling = new JobHostMetadataProvider(this);
            IExtensionRegistry       extensions       = new DefaultExtensionRegistry(_tooling);
            ITypeLocator             typeLocator      = new DefaultTypeLocator(ConsoleProvider.Out, extensions);
            IConverterManager        converterManager = new ConverterManager();
            IWebJobsExceptionHandler exceptionHandler = new WebJobsExceptionHandler();

            AddService <IQueueConfiguration>(_queueConfiguration);
            AddService <IConsoleProvider>(ConsoleProvider);
            AddService <IStorageAccountProvider>(_storageAccountProvider);
            AddService <IExtensionRegistry>(extensions);
            AddService <StorageClientFactory>(new StorageClientFactory());
            AddService <INameResolver>(new DefaultNameResolver());
            AddService <IJobActivator>(DefaultJobActivator.Instance);
            AddService <ITypeLocator>(typeLocator);
            AddService <IConverterManager>(converterManager);
            AddService <IWebJobsExceptionHandler>(exceptionHandler);
            AddService <IFunctionResultAggregatorFactory>(new FunctionResultAggregatorFactory());

            string value = ConfigurationUtility.GetSettingFromConfigOrEnvironment(Host.Constants.EnvironmentSettingName);

            IsDevelopment = string.Compare(Host.Constants.DevelopmentEnvironmentValue, value, StringComparison.OrdinalIgnoreCase) == 0;
        }