Skip to content

Latest commit

 

History

History
59 lines (40 loc) · 2.66 KB

index.rst

File metadata and controls

59 lines (40 loc) · 2.66 KB

Manual for library "Tools"

In this article:

You can evaluate a string describing a condition into a boolean using an SIM.Tools.ICondition. SIM.Tools.Condition class is its main implementation. It takes a string with the condition as an input parameter in the constructor. You can check the result of the condition using the property Result.

Check the next example:

.. literalinclude:: _static/CheckConditionSampleScript.ps1
  :language: powershell

This are the accepted operators:

  1. < -> less than
  2. > -> greater than
  3. = -> equals
  4. ! -> not equals
  5. AND -> 'and' logical operator
  6. OR -> 'or' logical operator
  7. NOT -> 'not' logical operator
  8. () -> Parentheses to modify operators preference

IMPORTANT: String literals must be enclosed by simple quotation marks: 'literal'

You can replace "keys" in a string for its corresponding "values" using a SIM.Tools.IResolvedText and a SIM.Tools.IResolver. SIM.Tools.ResolvedText class is the main implementation for IResolvedText. It takes the string with the keys and a IResolver as input parameters in the constructor. You can check the result using the property Text. For IResolver there is an implementation for v6 and v61 taking 2 parameter:

  1. An open connection with a SQL DB.
  2. An SQL Query containing the columns that will be used as keys. The column name must match the key name. The column value will be the value we will use.

You can check the result of the replacement using the property Text.

Check the next example:

.. literalinclude:: _static/ResolveNameV6SampleScript.ps1
  :language: powershell

Error handling:

  1. If braces do not match on the input text, a FormatException will be thrown.
  2. If a key value is not found among the columns returned by the query, or no entries are returned, an ApplicationException will be thrown. You can opt out of this error by adding a 3rd parameter to the ResolvedText constructor with the value false, like this:
$resolvedText = New-Object SIM.Tools.ResolvedText($input, $resolver, false)