Chronos Plugins 5.4.0
This documentation covers the plugin interfaces definitions and an example implementation.
Loading...
Searching...
No Matches
MockJobInspectingTask.cs
Go to the documentation of this file.
1using System.Linq;
2using System.Text;
4// ReSharper disable LocalizableElement
5
6namespace MockPlugin.Tasks
7{
8 // ReSharper disable once UnusedMember.Global
13 {
14 #region Normal task methods
15
17 {
18 if (mJitChecker != null)
19 {
20 System.Windows.Forms.MessageBox.Show(Helpers.Gui.MainWindow,
21 $"My enabled property {(mJitChecker(this, "Enabled") ? "will be set by a JIT expression" : "has an ordinary value")}", "JobInspectionDemo");
22 }
23 }
24
30 private void DisablePreviousTwin()
31 {
32 var prevTask = mJobInspector.CompleteSchedule
33 .TakeWhile(someTaskInfo => someTaskInfo.PluginTask != mJobInspector.CurrentTask.PluginTask).LastOrDefault();
34 if (prevTask?.PluginTask is JobInspectionDemo)
35 {
36 prevTask.Enabled = false;
37 }
38 }
39
41 {
43 }
44
45 private string GetJitInfo(ITaskInfo someTaskInfo, IAccessProperty somePropInfo)
46 {
47 if(mJitChecker == null)
48 {
49 return "N/A";
50 }
51 return mJitChecker(someTaskInfo.Task,somePropInfo.FullPath) ? "yes" : "no";
52 }
54 {
55 var sb = new StringBuilder();
56 var i = 1;
57 foreach (var someTaskInfo in mJobInspector.JobsTasks)
58 {
59 sb.AppendLine($"Task {i++}");
60 sb.AppendFormat("Class {0}, {1} properties\r\n",
61 someTaskInfo.Task.GetType().Name,
62 someTaskInfo.PropertyAccessInfos.Count());
63 foreach (var somePropInfo in someTaskInfo.PropertyAccessInfos)
64 {
65 sb.AppendFormat("Property {0}: {1}, jit? {2}\r\n",
66 somePropInfo.PropInfo.Name,
67 somePropInfo.PropInfo.GetValue(somePropInfo.BaseObject, null),
68 GetJitInfo(someTaskInfo,somePropInfo));
69 }
70 sb.AppendLine();
71 }
72 System.Windows.Forms.MessageBox.Show(Helpers.Gui.MainWindow, sb.ToString(), "Checked other tasks");
73 }
74
76 {
77 return "Snooping around";
78 }
79
80 #endregion Normal task methods
81
82 #region Job inspection
83
85
86 IInspectJob INeedToInspectOtherTasks.JobInspector
87 {
88 set => mJobInspector = value;
89 }
90
91 #endregion Job inspection
92 #region JIT Check
93
95 public JITCheckerDelegate JITChecker { set => mJitChecker = value; }
96 #endregion
97
98
99 }
100}
Classes and interfaces that are meant for plugins. The classes and interfaces below this namespace ar...
delegate bool JITCheckerDelegate(object task, string propertyPath)
The delegate that does the check for you.
Example task implementations. Since there are lots of things that can be done from a task,...
IWin32Window MainWindow
If you need to set the owner window yourself or want to show message boxes.
Definition: Helpers.cs:37
Static instance for access to utility functions and resources.
Definition: Helpers.cs:78
static IGuiHelper Gui
Utility functions for window handling.
Definition: Helpers.cs:92
To be implemented by the "task" part of a Chronos plugin. Public properties of the implementing type ...
void Execute()
Do whatever you have to do with your parameters.
void PostValidate()
Called after the schedule construction is completed.
string GetTaskAction()
Description of the tasks's action (for hints/time table)
void PreValidate()
Called before the schedule construction is completed.
Gives full access to other tasks's properties.
string FullPath
Full path, as must be given in property reference expressions.
Gives access to a task's implementation and to all user visible properties.
object Task
Task object, Chronos internal type.
ITask PluginTask
Gets the unwrapped ITask implementation if this is a plugin task, else null.
Allows to get information about other tasks within our task's job and about other jobs.
IEnumerable< ITaskInfo > JobsTasks
Enumerate the tasks in your task's job.
ITaskInfo CurrentTask
Gets the current Jobs current Task.
Implement this interface if you have to access other tasks within the schedule.
Implement this interface if you have to know (usually for validation) if a certain property of a give...
Shows how to get information about other tasks in the schedule.
void DisablePreviousTwin()
Shows how you can disable other tasks in the schedule creation phase. If there's a previous JobInspec...
JITCheckerDelegate JITChecker
Chronos will provide a function that you can use to check for JIT expressions in properties.
string GetJitInfo(ITaskInfo someTaskInfo, IAccessProperty somePropInfo)