public void SelectTask(string id)
        {
            _selectedTaskID = id;
            _taskFactory    = TaskRegistry.CreateFactoryInstance(id);

            SetupParameters();
        }
Exemple #2
0
        public SplitterPerTaskHoursTests()
        {
            this.contractRegistry = new ContractRegistry();
            var tokenTagger = new FungibleTokenTagger();
            var tokenPicker = new FungibleTokenPicker();

            this.permissionManager = new ContractExecutor(this.addressFactory.Create());
            this.workTracker       = new WorkTracker.WorkTracker(this.addressFactory.Create(), this.contractRegistry,
                                                                 this.permissionManager.Address);
            this.tokenManager = new TokenManager(
                this.addressFactory.Create(),
                this.permissionManager.Address,
                this.contractRegistry,
                tokenTagger,
                tokenPicker);
            this.splitterPerHours =
                new SplitterPerTaskHoursMock(this.addressFactory.Create(), this.tokenManager.Address, this.workTracker);
            this.taskRegistry = new TaskRegistry(this.addressFactory.Create(), this.contractRegistry,
                                                 this.permissionManager.Address, this.splitterPerHours.Address);
            this.contractRegistry.RegisterContract(this.taskRegistry);
            this.contractRegistry.RegisterContract(this.permissionManager);
            this.contractRegistry.RegisterContract(this.tokenManager);
            this.contractRegistry.RegisterContract(this.workTracker);
            this.contractRegistry.RegisterContract(this.splitterPerHours);
            this.InitializePermissions();
        }
Exemple #3
0
        public void RegisterMultipleTasksSomeWithSameName()
        {
            UsingTaskInfo[] taskInfos = { new UsingTaskInfo("CustomTask",           "CustomTask, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",           null),
                                          new UsingTaskInfo("YetAnotherCustomTask", "YetAnotherCustomTask, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null", null),
                                          new UsingTaskInfo("CustomTask",           "CustomTask, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null",           null) };

            TaskRegistry registryStub = TaskRegistryHelperMethods.CreateTaskRegistryAndRegisterTasks(taskInfos);

            //First assert that there are two unique buckets
            Assert.AreEqual(2, registryStub.AllTaskDeclarations.Count, "Expected only two buckets since two of three tasks have the same name!");

            //Now let's look at the bucket with only one task
            ArrayList singletonBucket = (ArrayList)registryStub.AllTaskDeclarations[taskInfos[1].TaskName];

            Assert.IsNotNull(singletonBucket, "Task AssemblyLoadInfo not found in TaskRegistry.AllTaskDeclarations!");
            Assert.AreEqual(1, singletonBucket.Count, "Expected only one AssemblyLoadInfo registered under this TaskName!");
            AssemblyLoadInfo singletonAssemblyLoadInfo = (AssemblyLoadInfo)singletonBucket[0];

            Assert.AreEqual(singletonAssemblyLoadInfo, taskInfos[1].AssemblyInfo, "Task AssemblyLoadInfo was not properly registered by TaskRegistry.RegisterTask!");

            //Finally let's look at the bucket with two tasks
            ArrayList duplicateBucket = (ArrayList)registryStub.AllTaskDeclarations[taskInfos[0].TaskName];

            Assert.IsNotNull(duplicateBucket, "Task AssemblyLoadInfo not found in TaskRegistry.AllTaskDeclarations!");
            Assert.AreEqual(2, duplicateBucket.Count, "Expected two AssemblyLoadInfos registered under this TaskName!");
            bool bothTaskVersionsFound = duplicateBucket.Contains(taskInfos[0].AssemblyInfo) && duplicateBucket.Contains(taskInfos[2].AssemblyInfo);

            Assert.IsTrue(bothTaskVersionsFound, "Expected both versions of the task to be registered in this bucket!");
        }
Exemple #4
0
        public TaskServiceTest()
        {
            _mockServiceProvider = new Mock <IServiceProvider>();
            _mockBroker          = new Mock <IQueueTBroker>();
            _mockDispatcher      = new Mock <IMessageDispatcher>();

            _taskServiceOptions  = new TaskServiceOptions();
            _queueServiceOptions = new QueueTServiceOptions {
                Broker = _mockBroker.Object
            };


            _taskRegistry = new TaskRegistry(
                NullLogger <TaskRegistry> .Instance,
                Options.Create(_taskServiceOptions));

            _taskService = new TaskService(
                NullLogger <TaskService> .Instance,
                _mockServiceProvider.Object,
                Options.Create(_queueServiceOptions),
                Options.Create(_taskServiceOptions),
                _taskRegistry,
                _mockDispatcher.Object);

            _syncTestMethod  = typeof(TestTaskClass).GetMethod(nameof(TestTaskClass.Multiply));
            _asyncTestMethod = typeof(TestTaskClass).GetMethod(nameof(TestTaskClass.MultiplyAsync));
        }
Exemple #5
0
        internal static TaskRegistry CreateTaskRegistryAndRegisterTasks(UsingTaskInfo[] taskInfos)
        {
            TaskRegistry registry = new TaskRegistry();

            foreach (UsingTaskInfo taskInfo in taskInfos)
            {
                registry.RegisterTask(taskInfo.UsingTask, RegistryExpander, LoggingServices, null);
            }

            return(registry);
        }
        private void RegisterSyncLogProvider(ApplicationConfiguration config, IRegistrationService resolver)
        {
            if (!TaskRegistry.IsNull() && !TaskRegistry().IsNull())
            {
                if (RecurringTaskLogProvider.IsNull() || RecurringTaskLogProvider().IsNull())
                {
                    RecurringTaskLogProvider = () => new RecurringTaskLogProvider();
                }

                resolver.Register(RecurringTaskLogProvider);
            }
        }
Exemple #7
0
        public void RegisterMultipleTasksWithSameNameAndSameAssembly()
        {
            UsingTaskInfo[] taskInfos = { new UsingTaskInfo("CustomTask",           null,                                                                          "Some\\Relative\\Path\\CustomTasks.dll"),
                                          new UsingTaskInfo("YetAnotherCustomTask", "YetAnotherCustomTask, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null", null),
                                          new UsingTaskInfo("CustomTask",           null,                                                                          "Some\\Relative\\Path\\CustomTasks.dll") };

            TaskRegistry registryStub = TaskRegistryHelperMethods.CreateTaskRegistryAndRegisterTasks(taskInfos);

            //two unique buckets
            Assert.AreEqual(2, registryStub.AllTaskDeclarations.Count, "Expected only two buckets since two of three tasks have the same name!");
            //three total tasks
            Assert.AreEqual(3, TaskRegistryHelperMethods.GetDeepCountOfRegisteredTasks(registryStub.AllTaskDeclarations), "Expected three total tasks registered in TaskRegistry!");
        }
Exemple #8
0
        public void InvalidToolPath()
        {
            //Note Engine's BinPath is distinct from the ToolsVersion's ToolsPath
            Engine     e          = new Engine();
            MockLogger mockLogger = new MockLogger();

            e.RegisterLogger(mockLogger);
            ToolsetState t = new ToolsetState(e, new Toolset("toolsversionname", "invalid||path"), new GetFiles(this.getFiles), new LoadXmlFromPath(this.loadXmlFromPath));

            TaskRegistry taskRegistry = (TaskRegistry)t.GetTaskRegistry(null);

            Console.WriteLine(mockLogger.FullLog);
            Assert.AreEqual(1, mockLogger.WarningCount, "Expected a warning for invalid character in toolpath");
        }
Exemple #9
0
        public void TasksNoLongerRegisteredAfterClearCalled()
        {
            UsingTaskInfo[] taskInfos = { new UsingTaskInfo("CustomTask",           "CustomTask, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null",           null),
                                          new UsingTaskInfo("YetAnotherCustomTask", "YetAnotherCustomTask, Version=9.0.0.0, Culture=neutral, PublicKeyToken=null", null),
                                          new UsingTaskInfo("MyCustomTask",         "CustomTask, Version=2.0.0.0, Culture=neutral, PublicKeyToken=null",           null) };

            TaskRegistry registryStub = TaskRegistryHelperMethods.CreateTaskRegistryAndRegisterTasks(taskInfos);

            int registeredTaskCount = TaskRegistryHelperMethods.GetDeepCountOfRegisteredTasks(registryStub.AllTaskDeclarations);

            Assert.AreEqual(3, registeredTaskCount, "Expected three registered tasks in TaskRegistry.AllTaskDeclarations!");

            registryStub.Clear();

            registeredTaskCount = TaskRegistryHelperMethods.GetDeepCountOfRegisteredTasks(registryStub.AllTaskDeclarations);
            Assert.AreEqual(0, registeredTaskCount, "Expected no registered tasks in TaskRegistry.AllTaskDeclarations!");
        }
Exemple #10
0
        public void RegisterTaskSimple()
        {
            UsingTaskInfo[] taskInfos = { new UsingTaskInfo("CustomTask", "CustomTask, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", null) };

            TaskRegistry registryStub = TaskRegistryHelperMethods.CreateTaskRegistryAndRegisterTasks(taskInfos);

            int registeredTaskCount = TaskRegistryHelperMethods.GetDeepCountOfRegisteredTasks(registryStub.AllTaskDeclarations);

            Assert.AreEqual(1, registeredTaskCount, "Expected only one registered task in TaskRegistry.AllTaskDeclarations!");

            ArrayList taskAssemblyLoadInfoList = (ArrayList)registryStub.AllTaskDeclarations[taskInfos[0].TaskName];

            Assert.IsNotNull(taskAssemblyLoadInfoList, "Task AssemblyLoadInfo not found in TaskRegistry.AllTaskDeclarations!");
            Assert.AreEqual(1, taskAssemblyLoadInfoList.Count, "Expected only one AssemblyLoadInfo registered!");

            AssemblyLoadInfo taskAssemblyLoadInfo = (AssemblyLoadInfo)taskAssemblyLoadInfoList[0];

            Assert.AreEqual(taskAssemblyLoadInfo, taskInfos[0].AssemblyInfo, "Task AssemblyLoadInfo was not properly registered by TaskRegistry.RegisterTask!");
        }
Exemple #11
0
        public void WarningLoggedIfNoDefaultTasksFound()
        {
            //Note Engine's BinPath is distinct from the ToolsVersion's ToolsPath
            Engine     e          = new Engine();
            MockLogger mockLogger = new MockLogger();

            e.RegisterLogger(mockLogger);

            ToolsetState t = new ToolsetState(e, new Toolset("toolsversionname", "c:\\directory1\\directory2\\doesntexist"), new GetFiles(this.getFiles), new LoadXmlFromPath(this.loadXmlFromPath));

            TaskRegistry taskRegistry = (TaskRegistry)t.GetTaskRegistry(null);

            string[] unexpectedRegisteredTasks = { "a1", "a2", "a3", "a4", "b1", "c1", "d1", "e1", "f1", "g1", "g2", "g3", "11", "12", "13", "21" };

            Assert.AreEqual(1, mockLogger.WarningCount, "Expected 1 warning logged!");
            foreach (string unexpectedRegisteredTask in unexpectedRegisteredTasks)
            {
                Hashtable registeredTasks;
                Assert.IsFalse(taskRegistry.FindRegisteredTasks(unexpectedRegisteredTask, true, out registeredTasks),
                               String.Format("Unexpected task '{0}' registered!", unexpectedRegisteredTask));
            }
        }
        public TaskOptionsMenu(ITask task, ITranslationHelper translation) : this(translation)
        {
            _task           = task;
            _selectedTaskID = task.ID;
            _taskFactory    = TaskRegistry.CreateFactoryInstance(task.ID);
            _taskFactory.Initialize(task, translation);

            _nameTextBox.Text = task.Name;
            _renewPeriodDropDown.selectedOption = (int)_task.RenewPeriod;

            if (_task.RenewPeriod == Period.Weekly)
            {
                _weekdaysDropDown.selectedOption = (_task.RenewDate.DayOfMonth - 1) % 7;
            }
            else if (_task.RenewPeriod != Period.Never)
            {
                _daysDropDown.selectedOption    = _task.RenewDate.DayOfMonth;
                _seasonsDropDown.selectedOption = _task.RenewDate.SeasonIndex;
            }

            SetupParameters();
        }
Exemple #13
0
        public void RegisterMultipleTasksWithDifferentNamesFromSameAssembly()
        {
            UsingTaskInfo[] taskInfos = { new UsingTaskInfo("CustomTask",           "CustomTasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", null),
                                          new UsingTaskInfo("YetAnotherCustomTask", null,                                                                 "bin\\Assemblies\\YetAnotherCustomTask.dll"),
                                          new UsingTaskInfo("AnotherCustomTask",    "CustomTasks, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null", null) };

            TaskRegistry registryStub = TaskRegistryHelperMethods.CreateTaskRegistryAndRegisterTasks(taskInfos);

            int registeredTaskCount = TaskRegistryHelperMethods.GetDeepCountOfRegisteredTasks(registryStub.AllTaskDeclarations);

            Assert.AreEqual(3, registeredTaskCount, "Expected three registered tasks in TaskRegistry.AllTaskDeclarations!");

            foreach (UsingTaskInfo taskInfo in taskInfos)
            {
                ArrayList taskAssemblyLoadInfoList = (ArrayList)registryStub.AllTaskDeclarations[taskInfo.TaskName];
                Assert.IsNotNull(taskAssemblyLoadInfoList, "Task AssemblyLoadInfo not found in TaskRegistry.AllTaskDeclarations!");
                Assert.AreEqual(1, taskAssemblyLoadInfoList.Count, "Expected only one AssemblyLoadInfo registered under this TaskName!");

                AssemblyLoadInfo taskAssemblyLoadInfo = (AssemblyLoadInfo)taskAssemblyLoadInfoList[0];
                Assert.AreEqual(taskAssemblyLoadInfo, taskInfo.AssemblyInfo, "Task AssemblyLoadInfo was not properly registered by TaskRegistry.RegisterTask!");
            }
        }
        public override TaskData ReadJson(JsonReader reader, Type objectType, TaskData?existingValue, bool hasExistingValue, JsonSerializer serializer)
        {
            IDictionary <string, List <ITask> > map = new Dictionary <string, List <ITask> >();

            if (JObject.Load(reader)["Tasks"] is not JObject json)
            {
                throw new JsonReaderException("Object with key \"Tasks\" not found");
            }

            foreach (var save in json)
            {
                if (save.Value is JArray taskArray)
                {
                    List <ITask> tasks = new List <ITask>();

                    foreach (JObject taskObject in taskArray)
                    {
                        string id = taskObject.Value <string>("ID");

                        if (taskObject.ToObject(TaskRegistry.GetTaskTypeOrDefault(id)) is ITask task)
                        {
                            tasks.Add(task);
                        }
                        else
                        {
                            throw new JsonReaderException("Unable to deserialize ITask");
                        }
                    }

                    map.Add(save.Key, tasks);
                }
            }

            return(new TaskData()
            {
                Tasks = map
            });
        }
Exemple #15
0
        public void AllUsingTaskAttributesAreExpanded()
        {
            UsingTaskInfo[] taskInfos = { new UsingTaskInfo("$(Property1)@(ThirdItem)$(Property2)", null,                                                                              "Some\\$(Property3)\\Path\\CustomTasks.dll"),
                                          new UsingTaskInfo("YetAnotherCustomTask",                 "$(Property4)@(ThirdItem), Version=9.0.0.0, Culture=neutral, PublicKeyToken=null", null),
                                          new UsingTaskInfo("Custom$(Property5)Task",               null,                                                                              "Some\\Relative\\Path\\CustomTasks.dll", "'@(ThirdItem)$(Property1)' == 'ThirdValue1Value1'") };

            TaskRegistry registryStub = TaskRegistryHelperMethods.CreateTaskRegistryAndRegisterTasks(taskInfos);

            int registeredTaskCount = TaskRegistryHelperMethods.GetDeepCountOfRegisteredTasks(registryStub.AllTaskDeclarations);

            Assert.AreEqual(3, registeredTaskCount, "Expected three registered tasks in TaskRegistry.AllTaskDeclarations!");

            foreach (UsingTaskInfo taskInfo in taskInfos)
            {
                UsingTaskInfo expandedTaskInfo         = taskInfo.CopyAndExpand(TaskRegistryHelperMethods.RegistryExpander);
                ArrayList     taskAssemblyLoadInfoList = (ArrayList)registryStub.AllTaskDeclarations[expandedTaskInfo.TaskName];
                Assert.IsNotNull(taskAssemblyLoadInfoList, "Task AssemblyLoadInfo not found in TaskRegistry.AllTaskDeclarations!");
                Assert.AreEqual(1, taskAssemblyLoadInfoList.Count, "Expected only one AssemblyLoadInfo registered under this TaskName!");

                AssemblyLoadInfo taskAssemblyLoadInfo = (AssemblyLoadInfo)taskAssemblyLoadInfoList[0];
                Assert.AreEqual(taskAssemblyLoadInfo, expandedTaskInfo.AssemblyInfo, "Task AssemblyLoadInfo was not properly registered by TaskRegistry.RegisterTask!");
            }
        }
Exemple #16
0
        private static void CheckBackupTask()
        {
            var service  = TaskRegistry.GetInstance();
            var task     = (Backup)service["Backup"];
            var srcFiles = new[]
            {
                "C:\\Temp\\NStub\\**",
                //"C:\\Temp\\raabe.jpg",
                //"C:\\Temp\\NStub"
            };
            var dstFiles = new[]
            {
                "C:\\Temp\\destination",
                //"C:\\Temp\\destination\\raabe.jpg",
            };

            //ArrayList sourceFiles = new ArrayList(srcFiles);
            //var cparr = sourceFiles.ToArray(typeof(TaskExtension));
            task.SourceFiles = TaskItems(srcFiles);
            //task.DestinationFolder = TaskItems(dstFiles);
            task.DestinationFolder = new TaskItem("C:\\Temp\\destination");
            var result = task.Execute();
        }
Exemple #17
0
        public void DefaultTasksAreFoundInToolsPath()
        {
            //Note Engine's BinPath is distinct from the ToolsVersion's ToolsPath
            Engine       e = new Engine();
            ToolsetState t = new ToolsetState(e, new Toolset("toolsversionname", "c:\\directory1\\directory2"), new GetFiles(this.getFiles), new LoadXmlFromPath(this.loadXmlFromPath));

            TaskRegistry taskRegistry = (TaskRegistry)t.GetTaskRegistry(null);

            string[] expectedRegisteredTasks   = { "a1", "a2", "a3", "a4", "b1", "e1", "g1", "g2", "g3" };
            string[] unexpectedRegisteredTasks = { "c1", "d1", "f1", "11", "12", "13", "21" };

            foreach (string expectedRegisteredTask in expectedRegisteredTasks)
            {
                Hashtable registeredTasks;
                Assert.IsTrue(taskRegistry.FindRegisteredTasks(expectedRegisteredTask, true, out registeredTasks),
                              String.Format("Expected task '{0}' registered!", expectedRegisteredTask));
            }
            foreach (string unexpectedRegisteredTask in unexpectedRegisteredTasks)
            {
                Hashtable registeredTasks;
                Assert.IsFalse(taskRegistry.FindRegisteredTasks(unexpectedRegisteredTask, true, out registeredTasks),
                               String.Format("Unexpected task '{0}' registered!", unexpectedRegisteredTask));
            }
        }
Exemple #18
0
        /// <summary>
        /// Used to load information about default MSBuild tasks i.e. tasks that do not need to be explicitly declared in projects
        /// with the &lt;UsingTask&gt; element. Default task information is read from special files, which are located in the same
        /// directory as the MSBuild binaries.
        /// </summary>
        /// <remarks>
        /// 1) a default tasks file needs the &lt;Project&gt; root tag in order to be well-formed
        /// 2) the XML declaration tag &lt;?xml ...&gt; is ignored
        /// 3) comment tags are always ignored regardless of their placement
        /// 4) the rest of the tags are expected to be &lt;UsingTask&gt; tags
        /// </remarks>
        /// <param name="loggingServices">The logging services to use to log during this registration.</param>
        /// <param name="buildEventContext">The build event context to use to log during this registration.</param>
        private void RegisterDefaultTasks(ILoggingService loggingServices, BuildEventContext buildEventContext, ProjectRootElementCache projectRootElementCache)
        {
            if (!_defaultTasksRegistrationAttempted)
            {
                try
                {
                    _defaultTaskRegistry = new TaskRegistry(projectRootElementCache);

                    InitializeProperties(loggingServices, buildEventContext);

                    string[] defaultTasksFiles = GetTaskFiles(_getFiles, loggingServices, buildEventContext, DefaultTasksFilePattern, ToolsPath, "DefaultTasksFileLoadFailureWarning");
                    LoadAndRegisterFromTasksFile(ToolsPath, defaultTasksFiles, loggingServices, buildEventContext, DefaultTasksFilePattern, "DefaultTasksFileFailure", projectRootElementCache, _defaultTaskRegistry);
                }
                finally
                {
                    _defaultTasksRegistrationAttempted = true;
                }
            }
        }
        /// <summary>
        /// Register all aspects into dependency resolver
        /// </summary>
        /// <returns></returns>
        public IServiceContainer Bootstrap(params Assembly[] scanAssemblies)
        {
            // Proc config validation
            ApplicationConfiguration config = null;

            try
            {
                config = ApplicationConfiguration.Instance;
            }
            catch { }
            finally
            {
                if (config.IsNull())
                {
                    throw new Exception("Signals.Core.Configuration.ApplicationConfiguration is not provided. Please use a configuration provider to provide configuration values!");
                }
            }

            if (DependencyResolver.IsNull() || DependencyResolver().IsNull())
            {
                throw new Exception("Dependency resolver not configured");
            }

            var resolver = DependencyResolver();

            if (!Logging.IsNull() && !Logging().IsNull())
            {
                resolver.Register(typeof(ILogger), Logging());
            }
            if (!Auditing.IsNull() && !Auditing().IsNull())
            {
                resolver.Register(typeof(IAuditProvider), Auditing());
            }
            if (!Cache.IsNull() && !Cache().IsNull())
            {
                resolver.Register(typeof(ICache), Cache());
            }
            if (!Localization.IsNull() && !Localization().IsNull())
            {
                resolver.Register(typeof(ILocalizationProvider), Localization());
            }
            if (!Storage.IsNull() && !Storage().IsNull())
            {
                resolver.Register(typeof(IStorageProvider), Storage());
            }
            if (!MessageChannel.IsNull() && !MessageChannel().IsNull())
            {
                resolver.Register(typeof(IMessageChannel), MessageChannel());
            }
            if (!AuthenticationManager.IsNull() && !AuthenticationManager().IsNull())
            {
                resolver.Register(typeof(IAuthenticationManager), AuthenticationManager());
            }
            if (!AuthorizationManager.IsNull() && !AuthorizationManager().IsNull())
            {
                resolver.Register(typeof(IAuthorizationManager), AuthorizationManager());
            }
            if (!TaskRegistry.IsNull() && !TaskRegistry().IsNull())
            {
                resolver.Register(typeof(ITaskRegistry), TaskRegistry());
            }
            if (!PermissionProvider.IsNull() && !PermissionProvider().IsNull())
            {
                resolver.Register(typeof(IPermissionProvider), PermissionProvider());
            }
            if (!Benchmarker.IsNull() && !Benchmarker().IsNull())
            {
                resolver.Register(typeof(IBenchmarker), Benchmarker());
            }
            if (!PermissionManager.IsNull() && !PermissionManager().IsNull())
            {
                resolver.Register(typeof(IPermissionManager), PermissionManager());
            }

            resolver.Register <CriticalErrorCallbackManager>();
            resolver.Register <IProcessFactory, ProcessFactory>();
            resolver.Register <IProcessExecutor, ProcessExecutor>();

            resolver.Register <IBusinessProcessContext, BusinessProcessContext>();
            resolver.Register <IApiProcessContext, ApiProcessContext>();
            resolver.Register <IDistributedProcessContext, DistributedProcessContext>();
            resolver.Register <IFileExportProcessContext, FileExportProcessContext>();
            resolver.Register <IFileImportProcessContext, FileImportProcessContext>();
            resolver.Register <IRecurringProcessContext, RecurringProcessContext>();

            resolver.Register <Mediator>();

            RegisterProcesses(config, resolver, scanAssemblies);
            RegisterErrorHendling(config, resolver);
            RegisterJsonSerializerSettings(config, resolver);
            RegisterSmtp(config, resolver);
            RegisterSyncLogProvider(config, resolver);

            var services = SystemBootstrapper.Init(resolver, scanAssemblies);

            return(services);
        }
Exemple #20
0
 public TaskRegistryTest()
 {
     _serviceOptions = new TaskServiceOptions();
     _taskRegistry   = new TaskRegistry(NullLogger <TaskRegistry> .Instance, Options.Create(_serviceOptions));
     _testMethod     = typeof(TestTaskClass).GetMethod(nameof(TestTaskClass.Multiply));
 }
Exemple #21
0
        public void Install(IWindsorContainer container, IConfigurationStore store)
        {
            if (ViewModelBase.IsInDesignModeStatic)
            {
                container.Register(Component.For <ITaskService>().ImplementedBy <DesignTaskService>());

                //container.Register(Component.For<TaskContext>().ImplementedBy<DesignTaskContext>());
                container.Register(AllTypes.FromAssemblyContaining <DesignTaskService>()
                                   .InSameNamespaceAs <DesignTaskService>()
                                   .If(fil => fil.Name == "DesignTaskContext")
                                   .Configure(e =>
                {
                    var bs = e.Implementation.BaseType;
                    e.Forward(bs);
                    e.Named("TaskContext");
                })
                                   );

                container.Register(Component.For <IOService>().ImplementedBy <DesignIOService>());

                //container.Register(Component.For<BackupDataRepository>().ImplementedBy<Jedzia.BackBock.ViewModel.Design.Data.DesignBackupDataRepository>());
                container.Register(Component.For <ISettingsProvider>().ImplementedBy <DesignSettingsProvider>());
                container.Register(Component.For <IBackupDataService>().ImplementedBy <ViewModel.Design.Data.DesignBackupDataService>());
            }
            else
            {
                container.Register(Component.For <ITaskService>()
                                   .UsingFactoryMethod(
                                       (a, b) =>
                {
                    var taskService = TaskRegistry.GetInstance();
                    // taskService.Register( ... additional tasks)
                    return(taskService);
                })
                                   );

                //container.Register(Component.For<DesignTaskContext>()
                //  .ImplementedBy<DesignTaskContext>().
                //.WithServiceBase());


                //container.Register(Component.For<TaskContext>().ImplementedBy<ApplicationTaskContext>());
                container.Register(AllTypes.FromAssemblyNamed("Jedzia.BackBock.TaskContext")
                                   .Where(type => type.Name == "ApplicationTaskContext")
                                   .Configure(e =>
                {
                    var bs = e.Implementation.BaseType;
                    e.Forward(bs);
                })
                                   );



                container.Register(Component.For <IOService>().ImplementedBy <FileIOService>());

                // Register collection resolver, needed by the BackupDataService dependencies.
                container.Kernel.Resolver.AddSubResolver(new CollectionResolver(container.Kernel, false));
                //container.Register(Component.For<BackupDataRepository>().ImplementedBy<Jedzia.BackBock.ViewModel.Design.Data.DesignBackupDataRepository>());

                container.Register(Component.For <BackupDataRepository>().ImplementedBy <RepositoryLogger>()
                                   //.ServiceOverrides(ServiceOverride.ForKey("logger"))
                                   //.Named("logger")
                                   );

                container.Register(AllTypes.FromAssemblyContaining <IBackupDataService>()
                                   .BasedOn(typeof(BackupDataRepository)).WithServiceBase()
                                   //.Configure(c => c.ServiceOverrides(new { First = "first" }))
                                   //.Configure(c => c.Interceptors<LoggerInterceptor>())
                                   );
                container.Register(AllTypes.FromAssemblyContaining <MainWindowViewModel>()
                                   .BasedOn(typeof(BackupDataRepository)).WithServiceBase()
                                   .If(t => t.Name.EndsWith("Repository"))
                                   //.Configure(c => c.Interceptors<LoggerInterceptor>())
                                   /*.Configure(c => c.Interceptors(typeof(RepositoryLogger)))*/);
                container.Register(AllTypes.FromAssemblyNamed("Jedzia.BackBock.Data.Xml")
                                   .BasedOn(typeof(BackupDataRepository)).WithServiceBase()
                                   //.Configure(c => c.ServiceOverrides(ServiceOverride.ForKey("logger")))
                                   //.Configure(c => c.Interceptors<LoggerInterceptor>())
                                   );



                //container.Register(Component.For<BackupDataRepository>().ImplementedBy<Jedzia.BackBock.ViewModel.Design.Data.TestBackupDataRepository>());
                //container.Register(Component.For<BackupDataRepository>().ImplementedBy<Jedzia.BackBock.Data.Xml.XmlDataRepository>());

                //container.Register(Component.For<IBackupDataService>().ImplementedBy<BackupDataService>());
                //container.Register(Component.For<IBackupDataService>().ImplementedBy<BackupDataService>()
                //    .Interceptors(typeof(BackupDataRepository), typeof(RepositoryLogger)));
                //container.Register(Component.For<IBackupDataService>().ImplementedBy<BackupDataService>()
                //     .Proxy.AdditionalInterfaces(typeof(BackupDataRepository))
                //    .Interceptors(typeof(RepositoryLogger)));

                //container.Register(Component.For<IBackupDataService>()
                //  .ServiceOverrides(new { repositories = "logger" })
                //.ImplementedBy<BackupDataService>()
                // );

                //container.Register(Component.For<LoggerInterceptor>());
                container.Register(Component
                                   .For <IBackupDataService>()
                                   .ImplementedBy <BackupDataService>()
                                   //.Interceptors<LoggerInterceptor>()
                                   );

                container.Register(Component.For <Settings>().Instance(Settings.Default));
                container.Register(Component.For <ISettingsProvider>().ImplementedBy <SettingsProvider>());
            }


            //container.Register(Component.For<ProxyDings>().Named("Heiner"));
            container.Register(
                // Decorator
                Component.For <IDings>().ImplementedBy <ProxyDings>().LifestyleTransient(),
                // Decorated object.
                Component.For <IDings>().ImplementedBy <Dings>()
                );

            container.AddFacility <TypedFactoryFacility>();

            container.Register(Component
                               .For <IDingsFactory>()
                               .AsFactory()
                               .LifestyleTransient()
                               );
        }
Exemple #22
0
 public void Setup()
 {
     tr = TaskRegistry.GetInstance();
     tr.Reset();
 }
Exemple #23
0
        /// <summary>
        /// Do the actual loading of the tasks or override tasks file and register the tasks in the task registry
        /// </summary>
        private void LoadAndRegisterFromTasksFile(string searchPath, string[] defaultTaskFiles, ILoggingService loggingServices, BuildEventContext buildEventContext, string defaultTasksFilePattern, string taskFileError, ProjectRootElementCache projectRootElementCache, TaskRegistry registry)
        {
            foreach (string defaultTasksFile in defaultTaskFiles)
            {
                try
                {
                    // Important to keep the following line since unit tests use the delegate.
                    ProjectRootElement projectRootElement;
                    if (_loadXmlFromPath != null)
                    {
                        XmlDocumentWithLocation defaultTasks = _loadXmlFromPath(defaultTasksFile);
                        projectRootElement = ProjectRootElement.Open(defaultTasks);
                    }
                    else
                    {
                        projectRootElement = ProjectRootElement.Open(defaultTasksFile, projectRootElementCache, false /*The tasks file is not a explicitly loaded file*/);
                    }

                    foreach (ProjectElement elementXml in projectRootElement.Children)
                    {
                        ProjectUsingTaskElement usingTask = elementXml as ProjectUsingTaskElement;

                        if (null == usingTask)
                        {
                            ProjectErrorUtilities.ThrowInvalidProject
                                (
                                elementXml.Location,
                                "UnrecognizedElement",
                                elementXml.XmlElement.Name
                                );
                        }

                        TaskRegistry.RegisterTasksFromUsingTaskElement<ProjectPropertyInstance, ProjectItemInstance>
                            (
                            loggingServices,
                            buildEventContext,
                            Path.GetDirectoryName(defaultTasksFile),
                            usingTask,
                            registry,
                            _expander,
                            ExpanderOptions.ExpandProperties
                            );
                    }
                }
                catch (XmlException e)
                {
                    // handle XML errors in the default tasks file
                    ProjectFileErrorUtilities.VerifyThrowInvalidProjectFile(false, new BuildEventFileInfo(e), taskFileError, e.Message);
                }
                catch (Exception e)
                {
                    if (ExceptionHandling.NotExpectedException(e))
                    {
                        // Catching Exception, but rethrowing unless it's an IO related exception.
                        throw;
                    }

                    loggingServices.LogError(buildEventContext, new BuildEventFileInfo(defaultTasksFile), taskFileError, e.Message);
                    break;
                }
            }
        }
Exemple #24
0
        /// <summary>
        /// Used to load information about MSBuild override tasks i.e. tasks that override tasks declared in tasks or project files.
        /// </summary>
        private void RegisterOverrideTasks(ILoggingService loggingServices, BuildEventContext buildEventContext, ProjectRootElementCache projectRootElementCache)
        {
            if (!_overrideTasksRegistrationAttempted)
            {
                try
                {
                    _overrideTaskRegistry = new TaskRegistry(projectRootElementCache);
                    bool overrideDirectoryExists = false;

                    try
                    {
                        // Make sure the override directory exists and is not empty before trying to find the files
                        if (!String.IsNullOrEmpty(_overrideTasksPath))
                        {
                            if (Path.IsPathRooted(_overrideTasksPath))
                            {
                                if (null != _directoryExists)
                                {
                                    overrideDirectoryExists = _directoryExists(_overrideTasksPath);
                                }
                                else
                                {
                                    overrideDirectoryExists = Directory.Exists(_overrideTasksPath);
                                }
                            }

                            if (!overrideDirectoryExists)
                            {
                                string rootedPathMessage = ResourceUtilities.FormatResourceString("OverrideTaskNotRootedPath", _overrideTasksPath);
                                loggingServices.LogWarning(buildEventContext, null, new BuildEventFileInfo(String.Empty /* this warning truly does not involve any file*/), "OverrideTasksFileFailure", rootedPathMessage);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        if (ExceptionHandling.NotExpectedException(e))
                        {
                            // Catching Exception, but rethrowing unless it's an IO related exception.
                            throw;
                        }

                        string rootedPathMessage = ResourceUtilities.FormatResourceString("OverrideTaskProblemWithPath", _overrideTasksPath, e.Message);
                        loggingServices.LogWarning(buildEventContext, null, new BuildEventFileInfo(String.Empty /* this warning truly does not involve any file*/), "OverrideTasksFileFailure", rootedPathMessage);
                    }

                    if (overrideDirectoryExists)
                    {
                        InitializeProperties(loggingServices, buildEventContext);
                        string[] overrideTasksFiles = GetTaskFiles(_getFiles, loggingServices, buildEventContext, OverrideTasksFilePattern, _overrideTasksPath, "OverrideTasksFileLoadFailureWarning");

                        // Load and register any override tasks
                        LoadAndRegisterFromTasksFile(_overrideTasksPath, overrideTasksFiles, loggingServices, buildEventContext, OverrideTasksFilePattern, "OverrideTasksFileFailure", projectRootElementCache, _overrideTaskRegistry);
                    }
                }
                finally
                {
                    _overrideTasksRegistrationAttempted = true;
                }
            }
        }
Exemple #25
0
        public override void draw(SpriteBatch b)
        {
            string title = _translation.Get("ui.tasks.new");
            int    iconY = okButton.bounds.Y;

            b.Draw(Game1.fadeToBlackRect, Game1.graphics.GraphicsDevice.Viewport.Bounds, Color.Black * 0.75f);
            SpriteText.drawStringWithScrollCenteredAt(b, title, xPositionOnScreen + width / 2, yPositionOnScreen - 96);

            _textBox.Draw(b);

            if (closeTipButton.visible = DeluxeJournalMod.Instance?.Config?.ShowSmartAddTip ?? true)
            {
                string text             = Game1.parseText(_translation.Get("ui.tasks.new.smarttip"), Game1.smallFont, 396);
                int    extraLineSpacing = Math.Max(0, text.Count(c => c == '\n') - 1) * Game1.smallFont.LineSpacing;

                DrawInfoBox(b, text, new Rectangle(_textBox.X - 32, _textBox.Y + 34, 544, 140 + extraLineSpacing));
                iconY += 80 + extraLineSpacing;

                if (new Rectangle(_textBox.X, _textBox.Y + 72, 480, 76).Contains(Game1.getOldMouseX(), Game1.getOldMouseY()))
                {
                    closeTipButton.draw(b);
                }
            }

            optionsButton.draw(b);
            cancelButton.draw(b);
            okButton.draw(b, (_textBox.Text.Length > 0) ? Color.White : Color.Gray * 0.8f, 0.88f);
            smartOkButton.draw(b, (_textBox.Text.Length > 0 && _taskParser.MatchFound()) ? Color.White : Color.Gray * 0.8f, 0.88f);

            if (smartTypeIconCC.visible = _taskParser.MatchFound())
            {
                Item?  item = _taskParser.SmartIconItem;
                NPC?   npc  = _taskParser.SmartIconNPC;
                string?name = _taskParser.SmartIconName;

                smartTypeIconCC.bounds.Y = iconY;
                smartItemIcon.bounds.Y   = iconY;
                smartNPCIcon.bounds.Y    = iconY;
                smartNameIcon.bounds.Y   = iconY;

                smartItemIcon.visible = item != null;
                smartNPCIcon.visible  = npc != null;
                smartNameIcon.visible = name != null;

                TaskRegistry.GetTaskIcon(_taskParser.ID).DrawIcon(b, smartTypeIconCC.bounds, Color.White);
                smartNameIcon.draw(b);

                if (npc != null)
                {
                    smartNPCIcon.draw(b);
                    CharacterIcon.DrawIcon(b, npc.Name, new Rectangle(smartNPCIcon.bounds.X + 8, smartNPCIcon.bounds.Y + 8, 40, 40));
                }

                if (item != null)
                {
                    smartItemIcon.bounds.X = smartNPCIcon.bounds.X + (smartNPCIcon.visible ? smartItemIcon.bounds.Width + 4 : 0);
                    smartItemIcon.draw(b);

                    item.drawInMenu(b,
                                    new Vector2(smartItemIcon.bounds.X - (item.ParentSheetIndex == SObject.wood ? 6 : 2), smartItemIcon.bounds.Y - 2),
                                    0.75f, 1.0f, 0.9f,
                                    StackDrawType.Draw,
                                    Color.White,
                                    false);
                }
            }

            if (_hoverText.Length > 0)
            {
                drawHoverText(b, _hoverText, Game1.dialogueFont);
            }
        }