IBinaryAction<T>.Run Method (IActionContext)
Defines the operations that are performed when the condition is met in the health definition. Returns the result of the operation.
Namespace: Microsoft.WindowsServerSolutions.NetworkHealth.Engine
Assembly: NetworkHealthEngine (in NetworkHealthEngine.dll)
Syntax
ActionResult<T> Run(
IActionContext context
)
ActionResult<T>^ Run(
IActionContext^ context
)
Function Run (
context As IActionContext
) As ActionResult(Of T)
Parameters
context
Type: Microsoft.WindowsServerSolutions.NetworkHealth.Engine.IActionContextThe execution context.
Return Value
Type: Microsoft.WindowsServerSolutions.NetworkHealth.Engine.ActionResult<T>
A instance of ActionResult<T>.
Remarks
The following code examples show how the IBinaryAction<T> interface can be implemented for different conditions.
Examples
public class SucceedCondition : IBinaryAction<bool>
{
public ActionResult<bool> Run(IActionContext context)
{
return new ActionResult<bool>(true, "This action will always return true");
}
}
public class ReturnStringAction : IBinaryAction<string>
{
public ActionResult<string> Run(IActionContext context)
{
return new ActionResult<string>("Hello World", "This action always returns \"Hello World\"");
}
}
public class FalseCondition : IBinaryAction<bool>
{
public ActionResult<bool> Run(IActionContext context)
{
return new ActionResult<bool>(false, "This action always returns false");
}
}
public class ThrowActionException : IBinaryAction<bool>
{
public ActionResult<bool> Run(IActionContext context)
{
throw new ActionRuntimeException("Evaluation condition action that throws an error");
}
}
public class TimeoutEvaluationError : IBinaryAction<bool>
{
public ActionResult<bool> Run(IActionContext context)
{
Thread.Sleep(5000);
return new ActionResult<bool>(true, "This action always returns true");
}
}
public class PowershellMissingError : IBinaryAction<bool>
{
public ActionResult<bool> Run(IActionContext context)
{
throw new PowershellMissingException("Evaluation condition that throws a Windows PowerShell missing error");
}
}
See Also
IBinaryAction<T> Interface
Microsoft.WindowsServerSolutions.NetworkHealth.Engine Namespace
Return to top