Example #1
0
 public DotqApi(ConnectionMultiplexer redis = null)
 {
     _redis              = redis ?? LocalRedis.Instance;
     _taskQueue          = new RedisTaskQueue(_redis);
     _resultStore        = new SimpleRedisTaskResultStore(_redis);
     _taskRegistry       = TaskRegistry.TaskRegistry.Instance;
     _redisPromiseClient = PromiseClientProvider.GetInstance(_redis);
     _redisPromiseServer = PromiseServerProvider.GetInstance();
 }
Example #2
0
 public SimpleWorker(IDotQueue <ITask> q, ITaskResultStore <string> r)
 {
     queue           = q;
     resultStore     = r;
     deserializer    = new DefaultTaskDeserializer();
     promiseResolver = new RedisPromiseServer();
     _taskRegistry   = TaskRegistry.TaskRegistry.Instance;
     _taskRegistry.DiscoverTasks();
 }
Example #3
0
        public void InteractionIsDisposed()
        {
            IArgumentProvider   arguments    = Substitute.For <IArgumentProvider>();
            ITaskRegistry       taskRegistry = Substitute.For <ITaskRegistry>();
            TestTaskInteraction interaction  = new TestTaskInteraction {
                Arguments = arguments
            };

            TestTaskExecution execution = new TestTaskExecution(arguments, taskRegistry, interaction);

            execution.ExecuteTask();
            interaction.DisposeCount.Should().Be(1);
        }
Example #4
0
        public void ExecutionGetsSpecifiedCommand()
        {
            IArgumentProvider arguments    = Substitute.For <IArgumentProvider>();
            ITaskRegistry     taskRegistry = Substitute.For <ITaskRegistry>();
            ITask             task         = Substitute.For <ITask>();

            arguments.Command.Returns("ExecutionGetsSpecifiedCommand");
            taskRegistry["ExecutionGetsSpecifiedCommand"].Returns(task);

            TaskExecution execution = Substitute.ForPartsOf <TaskExecution>(arguments, taskRegistry, null);

            execution.ExecuteTask();
            task.Received(1).Execute(Arg.Any <ITaskInteraction>());
        }
Example #5
0
        public void NoParameters()
        {
            ITaskRegistry    registry    = Substitute.For <ITaskRegistry>();
            UnknownTask      task        = new UnknownTask(registry, "GeneralHelp");
            ITaskInteraction interaction = Substitute.For <ITaskInteraction>();
            ILoggers         loggers     = Substitute.For <ILoggers>();

            interaction.Loggers.Returns(loggers);
            ILogger logger = Substitute.For <ILogger>();

            loggers[LoggerType.Status].Returns(logger);

            task.Execute(interaction).Should().Be(ExitCode.InvalidArgument);
            logger.Received().WriteLine(WriteStyle.Error, XTaskStrings.ErrorNoParametersSpecified);
        }
Example #6
0
 public TaskService(
     ILogger <TaskService> logger,
     IServiceProvider serviceProvider,
     IOptions <QueueTServiceOptions> appOptions,
     IOptions <TaskServiceOptions> taskOptions,
     ITaskRegistry taskRegistry,
     IMessageDispatcher messageDispatcher)
 {
     _logger            = logger;
     _serviceProvider   = serviceProvider;
     _appOptions        = appOptions.Value;
     _taskOptions       = taskOptions.Value;
     Registry           = taskRegistry;
     _messageDispatcher = messageDispatcher;
 }
Example #7
0
        public void UnknownTaskLogsHelp()
        {
            ITaskRegistry    registry    = Substitute.For <ITaskRegistry>();
            UnknownTask      task        = new UnknownTask(registry, "GeneralHelp");
            ITaskInteraction interaction = Substitute.For <ITaskInteraction>();
            ILoggers         loggers     = Substitute.For <ILoggers>();

            interaction.Loggers.Returns(loggers);
            ILogger logger = Substitute.For <ILogger>();

            loggers[LoggerType.Result].Returns(logger);

            task.Execute(interaction).Should().Be(ExitCode.InvalidArgument);
            logger.Received().WriteLine(WriteStyle.Fixed, "GeneralHelp");
        }
Example #8
0
        public void HelpOutputsUsage()
        {
            IArgumentProvider  arguments    = Substitute.For <IArgumentProvider>();
            ITaskRegistry      taskRegistry = Substitute.For <ITaskRegistry>();
            ITaskDocumentation docs         = Substitute.For <ITaskDocumentation>();
            ITask task = Substitute.For <ITask>();

            task.GetService <ITaskDocumentation>().Returns(docs);

            arguments.Command.Returns("HelpOutputsUsage");
            arguments.HelpRequested.Returns(true);
            taskRegistry["HelpOutputsUsage"].Returns(task);

            TaskExecution execution = Substitute.ForPartsOf <TaskExecution>(arguments, taskRegistry, null);

            execution.ExecuteTask();
            docs.Received(1).GetUsage(Arg.Any <ITaskInteraction>());
        }
Example #9
0
        public NotificationRegistry(
            ILogger <NotificationRegistry> logger,
            ITaskRegistry taskRegistry,
            IOptions <NotificationOptions> options)
        {
            _logger       = logger;
            _taskRegistry = taskRegistry;

            foreach (var notifications in options.Value.Notifications)
            {
                RegisteryNotification(notifications);
            }

            foreach (var subscription in options.Value.NotificationSubscriptions)
            {
                RegisterSubscription(subscription);
            }
        }
Example #10
0
        public void UnkownCommand()
        {
            ITaskRegistry     registry    = Substitute.For <ITaskRegistry>();
            UnknownTask       task        = new UnknownTask(registry, "GeneralHelp");
            ITaskInteraction  interaction = Substitute.For <ITaskInteraction>();
            IArgumentProvider arguments   = Substitute.For <IArgumentProvider>();
            string            commandName = "Foo";

            interaction.Arguments.Returns(arguments);
            interaction.Arguments.Command.Returns(commandName);
            ILoggers loggers = Substitute.For <ILoggers>();

            interaction.Loggers.Returns(loggers);
            ILogger logger = Substitute.For <ILogger>();

            loggers[LoggerType.Status].Returns(logger);

            task.Execute(interaction).Should().Be(ExitCode.InvalidArgument);
            logger.Received().WriteLine(WriteStyle.Error, XTaskStrings.UnknownCommand, commandName);
        }
Example #11
0
 public InteractiveTask(string prompt, ITaskRegistry registry, IConsoleService consoleService = null)
 {
     this.prompt = prompt;
     this.registry = registry;
     this.consoleService = consoleService ?? ConsoleHelper.Console;
 }
Example #12
0
 /// <summary>
 /// Execution handler for tasks running under MSBuild.
 /// </summary>
 /// <param name="services">Override services, can be null. Used to get services before falling back on defaults.</param>
 public BuildTaskExecution(MSBuildFramework.IBuildEngine buildEngine, ITaskOutputHandler outputHandler, IArgumentProvider argumentProvider, ITaskRegistry taskRegistry, ITypedServiceProvider services = null)
     : base(argumentProvider, taskRegistry, services)
 {
     _outputHandler = outputHandler;
     _buildEngine   = buildEngine;
 }
Example #13
0
 protected TaskExecution(IArgumentProvider argumentProvider, ITaskRegistry taskRegistry, ITypedServiceProvider services)
 {
     ArgumentProvider = argumentProvider;
     _taskRegistry    = taskRegistry;
     Services         = services;
 }
Example #14
0
 public HelpTask(ITaskRegistry registry, string generalHelp)
 {
     _registry    = registry;
     _generalHelp = generalHelp;
 }
Example #15
0
 protected TaskExecution(IArgumentProvider argumentProvider, ITaskRegistry taskRegistry, ITypedServiceProvider services)
 {
     this.ArgumentProvider = argumentProvider;
     this.taskRegistry = taskRegistry;
     this.Services = services;
 }
Example #16
0
 /// <summary>
 /// Execution handler for tasks running under MSBuild.
 /// </summary>
 /// <param name="services">Override services, can be null. Used to get services before falling back on defaults.</param>
 public BuildTaskExecution(MSBuildFramework.IBuildEngine buildEngine, ITaskOutputHandler outputHandler, IArgumentProvider argumentProvider, ITaskRegistry taskRegistry, ITypedServiceProvider services = null)
     : base(argumentProvider, taskRegistry, services)
 {
     this.outputHandler = outputHandler;
     this.buildEngine = buildEngine;
 }
Example #17
0
 public HelpTask(ITaskRegistry registry, string generalHelp)
 {
     this.registry    = registry;
     this.generalHelp = generalHelp;
 }
Example #18
0
 /// <summary>
 /// Sets the default task registry to the provided value.
 /// </summary>
 /// <param name="taskRegistry"></param>
 internal void SetTaskRegistry(ITaskRegistry taskRegistry)
 {
     ErrorUtilities.VerifyThrowArgumentNull(taskRegistry, "taskRegistry");
     defaultTasksRegistrationAttempted = true;
     defaultTaskRegistry = taskRegistry;
 }
Example #19
0
 /// <summary>
 /// Execution handler for tasks running under the console.
 /// </summary>
 /// <param name="services">Override services, can be null. Used to get services before falling back on defaults.</param>
 public ConsoleTaskExecution(IArgumentProvider argumentProvider, ITaskRegistry taskRegistry, ITypedServiceProvider services = null)
     : base(argumentProvider, taskRegistry, services)
 {
 }
Example #20
0
 public HelpTask(ITaskRegistry registry, string generalHelp)
 {
     _registry = registry;
     _generalHelp = generalHelp;
 }
Example #21
0
 public UnknownTask(ITaskRegistry registry, string generalHelp)
     : base(registry, generalHelp)
 {
 }
Example #22
0
 /// <summary>
 /// Sets the default task registry to the provided value.
 /// </summary>
 /// <param name="taskRegistry"></param>
 internal void SetTaskRegistry(ITaskRegistry taskRegistry)
 {
     ErrorUtilities.VerifyThrowArgumentNull(taskRegistry, nameof(taskRegistry));
     defaultTasksRegistrationAttempted = true;
     defaultTaskRegistry = taskRegistry;
 }
Example #23
0
 public HelpTask(ITaskRegistry registry, string generalHelp)
 {
     this.registry = registry;
     this.generalHelp = generalHelp;
 }
Example #24
0
        /// <summary>
        /// Creates an instance of this class for the given engine, specifying a tools version to
        /// use during builds of this project.
        /// </summary>
        /// <owner>RGoel</owner>
        /// <param name="engine">Engine that will build this project. May be null if the global engine is expected.</param>
        /// <param name="toolsVersion">Tools version to use during builds of this project instance. May be null,
        /// in which case we will use the value in the Project's ToolsVersion attribute, or else the engine
        /// default value.</param>
        public Project
        (
            Engine engine,
            string toolsVersion
        )
        {
#if MSBUILDENABLEVSPROFILING 
            try
            {
                DataCollection.CommentMarkProfile(8808, "Construct Project Using Old OM - Start");
#endif 
#if (!STANDALONEBUILD)
            using (new CodeMarkerStartEnd(CodeMarkerEvent.perfMSBuildProjectConstructBegin, CodeMarkerEvent.perfMSBuildProjectConstructEnd))
#endif
            {
                if (engine == null)
                {
                    engine = Engine.GlobalEngine;
                }

                this.parentEngine = engine;
                this.projectId = parentEngine.GetNextProjectId();
                this.projectBuildEventContext = new BuildEventContext(parentEngine.NodeId, BuildEventContext.InvalidTargetId, parentEngine.GetNextProjectId(), BuildEventContext.InvalidTaskId);

                this.isLoadedByHost = true;
                this.buildEnabled = BuildEnabledSetting.UseParentEngineSetting;

                this.isValidated = false;

                // Create a new XML document and add a <Project> element.  This way, the
                // project is always in a valid state from the beginning, and now somebody
                // can start programmatically adding stuff to the <Project>.
                this.mainProjectEntireContents = new XmlDocument();
                this.mainProjectElement = mainProjectEntireContents.CreateElement(XMakeElements.project, XMakeAttributes.defaultXmlNamespace);
                this.mainProjectEntireContents.AppendChild(mainProjectElement);


                // initialize all case-insensitive hash-tables
                this.conditionedPropertiesTable = new Hashtable(StringComparer.OrdinalIgnoreCase);
                this.evaluatedItemsByName = new Hashtable(StringComparer.OrdinalIgnoreCase);
                this.evaluatedItemsByNameIgnoringCondition = new Hashtable(StringComparer.OrdinalIgnoreCase);

                // Create the group collection.  All collection elements are stored here.
                this.rawGroups = new GroupingCollection(null /* null parent means this is the master collection */);

                // Initialize all property-related objects.
                // (see above for initialization of this.conditionedPropertiesTable)
                this.globalProperties = null;
                this.environmentProperties = null;
                this.reservedProperties = null;
                // We still create the rawPropertyGroups collection, but
                // it's just a facade over rawGroups
                this.rawPropertyGroups = new BuildPropertyGroupCollection(this.rawGroups);
                this.evaluatedProperties = new BuildPropertyGroup();

                // Initialize all item-related objects.
                // (see above for initialization of this.evaluatedItemsByName and this.evaluatedItemsByNameIgnoringCondition
                // We still create the rawItemGroups collection, but it's just a facade over rawGroups
                this.rawItemGroups = new BuildItemGroupCollection(this.rawGroups);
                this.evaluatedItems = new BuildItemGroup();
                this.evaluatedItemsIgnoringCondition = new BuildItemGroup();

                this.itemDefinitionLibrary = new ItemDefinitionLibrary(this);

                // Initialize all target- and task-related objects.
                this.usingTasks = new UsingTaskCollection();
                this.imports = new ImportCollection(this);
                this.taskRegistry = new TaskRegistry();
                this.targets = new TargetCollection(this);

                // Initialize the default targets, initial targets, and project file name.
                this.defaultTargetNames = new string[0];
                this.initialTargetNamesInMainProject = new ArrayList();
                this.initialTargetNamesInImportedProjects = new ArrayList();
                this.FullFileName = String.Empty;
                this.projectDirectory = String.Empty;

                this.projectExtensionsNode = null;

                // If the toolsVersion is null, we will use the value specified in
                // the Project element's ToolsVersion attribute, or else the default if that
                // attribute is not present.
                if (null != toolsVersion)
                {
                    this.ToolsVersion = toolsVersion;
                }

                this.MarkProjectAsDirtyForReprocessXml();
                // The project doesn't really need to be saved yet; there's nothing in it!
                this.dirtyNeedToSaveProjectFile = false;
                this.IsReset = false;

                // Grab some initial properties from the Engine.
                // Global properties and reserved properties need to be cloned, because
                // different projects may have different sets of properties or values
                // for these.  Environment properties don't have to be cloned, because
                // the environment is captured once at engine instantiation, and
                // shared by all projects thereafter.
                this.GlobalProperties = this.parentEngine.GlobalProperties;
                this.EnvironmentProperties = this.parentEngine.EnvironmentProperties;
            }
#if MSBUILDENABLEVSPROFILING 
            }
            finally
            {
                DataCollection.CommentMarkProfile(8809, "Construct Project Using Old OM - End");
            }
#endif
        }
Example #25
0
 /// <summary>
 /// Execution handler for tasks running under the console.
 /// </summary>
 /// <param name="services">Override services, can be null. Used to get services before falling back on defaults.</param>
 public ConsoleTaskExecution(IArgumentProvider argumentProvider, ITaskRegistry taskRegistry, ITypedServiceProvider services = null)
     : base(argumentProvider, taskRegistry, services)
 {
 }
Example #26
0
 public TestTaskExecution(IArgumentProvider argumentProvider, ITaskRegistry taskRegistry, ITaskInteraction interaction)
     : base(argumentProvider, taskRegistry, null)
 {
     this.interaction = interaction;
 }
Example #27
0
 public InteractiveTask(string prompt, ITaskRegistry registry, IConsoleService consoleService = null)
 {
     _prompt         = prompt;
     _registry       = registry;
     _consoleService = consoleService ?? ConsoleHelper.Console;
 }
Example #28
0
 public TaskManager(ITaskRegistry taskRegistry)
 {
     _taskRegistry = taskRegistry;
 }
Example #29
0
 public UnknownTask(ITaskRegistry registry, string generalHelp)
     : base(registry, generalHelp)
 {
 }
Example #30
0
 /// <summary>
 /// Background tasks registry
 /// </summary>
 public FluentApplicationBootstrapConfiguration AddTaskRegistry(ITaskRegistry taskRegistry)
 {
     TaskRegistry = taskRegistry;
     return(this);
 }