コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TaskSchedulerPollingJob"/> class.
        /// </summary>
        /// <param name="configProvider">The configuration provider to retrieve configuration.</param>
        /// <param name="repository">The repository to use.</param>
        /// <param name="dateTimeProvider">The date time provider to use.</param>
        /// <param name="facade">The task processor facade to use to submit tasks.</param>
        public TaskSchedulerPollingJob(ITaskProcessorConfigurationProvider configProvider, ITaskProcessorRepository repository, IDateTimeProvider dateTimeProvider, ITaskProcessorFacade facade)
        {
            if (configProvider == null)
            {
                throw new ArgumentNullException(nameof(configProvider));
            }

            if (repository == null)
            {
                throw new ArgumentNullException(nameof(repository));
            }

            if (dateTimeProvider == null)
            {
                throw new ArgumentNullException(nameof(dateTimeProvider));
            }

            if (facade == null)
            {
                throw new ArgumentNullException(nameof(facade));
            }

            this.configuration = configProvider.GetTaskSchedulerConfiguration();

            this.repository       = repository;
            this.dateTimeProvider = dateTimeProvider;
            this.facade           = facade;

            this.repository.ScheduledTasks.Added   += this.OnScheduledTaskAdded;
            this.repository.ScheduledTasks.Updated += this.OnScheduledTaskUpdated;
            this.repository.ScheduledTasks.Deleted += this.OnScheduledTaskDeleted;
        }
コード例 #2
0
        private void OnWindowLoaded(object sender, RoutedEventArgs e)
        {
            if (this.DataContext == null)
            {
                this.DataContext = RadoslavServiceLocator.DefaultInstance.ResolveSingle <MainViewModel>();

                ITaskProcessorConfigurationProvider configProvider = RadoslavServiceLocator.DefaultInstance.ResolveSingle <ITaskProcessorConfigurationProvider>();

                ITaskProcessorClientConfiguration config = configProvider.GetClientConfiguration();

                btnSubmitDemoTask.Visibility    = config.IsSupported <DemoTask>() ? Visibility.Visible : Visibility.Collapsed;
                btnPollingQueueTasks.Visibility = config.IsSupported <DemoPollingQueueTask>() ? Visibility.Visible : Visibility.Collapsed;
                btnScheduleTask.Visibility      = btnPollingQueueTasks.Visibility;
            }
        }
コード例 #3
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TaskWorkerFactory"/> class.
        /// </summary>
        /// <param name="configurationProvider">The configuration factory to provide task worker configuration.</param>
        /// <param name="locator">The service locator to resolve task worker instances.</param>
        /// <exception cref="ArgumentNullException">Parameter <paramref name="configurationProvider"/> or <paramref name="locator"/> is null.</exception>
        public TaskWorkerFactory(ITaskProcessorConfigurationProvider configurationProvider, IRadoslavServiceLocator locator)
        {
            if (configurationProvider == null)
            {
                throw new ArgumentNullException(nameof(configurationProvider));
            }

            if (locator == null)
            {
                throw new ArgumentNullException(nameof(locator));
            }

            this.locator = locator;

            this.configuration = configurationProvider.GetTaskWorkerConfiguration();
        }
コード例 #4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TaskWorkerBootstrap"/> class.
        /// </summary>
        /// <param name="configProvider">The configuration provider to use.</param>
        /// <param name="repository">The repository to use.</param>
        /// <param name="messageBus">The message bus to use.</param>
        /// <param name="taskWorkerFactory">The task worker factory to use.</param>
        /// <param name="dateTimeProvider">The date time provider to use.</param>
        /// <exception cref="ArgumentNullException">Parameter <paramref name="repository"/>, <paramref name="messageBus"/>,
        /// <paramref name="taskWorkerFactory"/> or <paramref name="dateTimeProvider"/> is null.</exception>
        public TaskWorkerBootstrap(ITaskProcessorConfigurationProvider configProvider, ITaskProcessorRepository repository, ITaskProcessorMessageBus messageBus, ITaskWorkerFactory taskWorkerFactory, IDateTimeProvider dateTimeProvider)
        {
            if (configProvider == null)
            {
                throw new ArgumentNullException("configProvider");
            }

            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }

            if (messageBus == null)
            {
                throw new ArgumentNullException("messageBus");
            }

            if (taskWorkerFactory == null)
            {
                throw new ArgumentNullException("taskWorkerFactory");
            }

            if (dateTimeProvider == null)
            {
                throw new ArgumentNullException("dateTimeProvider");
            }

            this.configuration = configProvider.GetTaskWorkerConfiguration();

            if (this.configuration == null)
            {
                throw new ArgumentException("'{0}' returned null configuration.".FormatInvariant(configProvider.GetType()), nameof(configProvider));
            }

            this.repository       = repository;
            this.messageBus       = messageBus;
            this.taskFactory      = taskWorkerFactory;
            this.dateTimeProvider = dateTimeProvider;
        }
コード例 #5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="TaskProcessorFacade"/> class.
        /// </summary>
        /// <param name="repository">The repository to use.</param>
        /// <param name="messageBus">The message bus to use.</param>
        /// <param name="dateTimeProvider">The date time provider to use.</param>
        /// <param name="appConfigConfigurationProvider">The configuration provider to read from App.config.</param>
        /// <exception cref="ArgumentNullException">Parameter <paramref name="repository"/>, <paramref name="messageBus"/>,
        /// <paramref name="dateTimeProvider"/> or <paramref name="appConfigConfigurationProvider"/> is null.</exception>
        public TaskProcessorFacade(
            ITaskProcessorRepository repository,
            ITaskProcessorMessageBus messageBus,
            IDateTimeProvider dateTimeProvider,
            ITaskProcessorConfigurationProvider appConfigConfigurationProvider)
        {
            Trace.WriteLine("ENTER: Constructing {0} ...".FormatInvariant(this.debugName));

            if (repository == null)
            {
                throw new ArgumentNullException("repository");
            }

            if (messageBus == null)
            {
                throw new ArgumentNullException("messageBus");
            }

            if (dateTimeProvider == null)
            {
                throw new ArgumentNullException("dateTimeProvider");
            }

            if (appConfigConfigurationProvider == null)
            {
                throw new ArgumentNullException("appConfigConfigurationProvider");
            }

            this.repository       = repository;
            this.messageBus       = messageBus;
            this.dateTimeProvider = dateTimeProvider;

            this.configuration = appConfigConfigurationProvider.GetClientConfiguration();

            Trace.WriteLine("EXIT: {0} constructed.".FormatInvariant(this.debugName));
        }