Click or drag to resize

TemplatedExpressionParser Class

Represents a template based token substitution parser that supports binary and advanced expressions.
Inheritance Hierarchy
SystemObject
  GSF.ParsingTemplatedExpressionParser

Namespace: GSF.Parsing
Assembly: GSF.Core (in GSF.Core.dll) Version: 2.4.218-beta+101eee949414e414795e55a6e73d88938f0177b8
Syntax
public class TemplatedExpressionParser
View Source

The TemplatedExpressionParser type exposes the following members.

Constructors
 NameDescription
Public methodTemplatedExpressionParser Creates a new TemplatedExpressionParser.
Public methodTemplatedExpressionParser(Char, Char, Char, Char) Creates a new TemplatedExpressionParser with desired delimiters.
Top
Properties
 NameDescription
Public propertyEndExpressionDelimiter Gets the character that identifies the end of an expression.
Public propertyEndTokenDelimiter Gets the character that identifies the end of a token.
Public propertyReservedSymbols Gets the reserved symbols - this includes all delimiters and expression operators.
Public propertyStartExpressionDelimiter Gets the character that identifies the start of an expression.
Public propertyStartTokenDelimiter Gets the character that identifies the beginning of a token.
Public propertyTemplatedExpression Gets or sets the templated expression to use.
Top
Methods
 NameDescription
Public methodEqualsDetermines whether the specified object is equal to the current object.
(Inherited from Object)
Public methodExecute Executes replacements using provided substitutions dictionary on the currently defined TemplatedExpression value and optionally evaluates any expressions.
Protected methodFinalizeAllows an object to try to free resources and perform other cleanup operations before it is reclaimed by garbage collection.
(Inherited from Object)
Public methodGetHashCodeServes as the default hash function.
(Inherited from Object)
Public methodGetTypeGets the Type of the current instance.
(Inherited from Object)
Protected methodMemberwiseCloneCreates a shallow copy of the current Object.
(Inherited from Object)
Public methodToStringReturns a string that represents the current object.
(Inherited from Object)
Top
Extension Methods
 NameDescription
Public Extension MethodGetEnumValueOrDefault Gets the enumeration constant for value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Public Extension MethodGetEnumValueOrDefaultT Gets the enumeration constant for this value, if defined in the enumeration, or a default value.
(Defined by EnumExtensions)
Top
Remarks

As an example, this parser can use a templated expression of the form:

C#
{CompanyAcronym}_{DeviceAcronym}[?{SignalType.Source}=Phasor[-{SignalType.Suffix}{SignalIndex}]]:{Signal.Acronymn}
then replace the tokens with actual values and properly evaluate the expressions. Example results could look like: GPA_SHELBY-PA1:IPHA and GPA_SHELBY:FREQ

Parser also supports more complex C# style expressions using the "eval{}" function, e.g.:

C#
eval{'{CompanyAcronym}'.Substring(0,3)}_{DeviceAcronym}eval{'[?{SignalType.Source}=Phasor[-{SignalType.Suffix}]]'.Length}

See Also