OperatorConverter - YiZhang-Paul/Mock_Up_Calculator GitHub Wiki
Namespace: ConverterClassLibrary
Implements: IOperatorConverter
Description: Provides semantic mappings between operators and numeric values. i.e. mapping the concept of factorial operator to value 0, when the actual operator can be expressed in various ways such as "!", "fact" or "fac". Such semantic mapping avoids binding values to an actual implementation/representation of operators, which can easily break the system if such implementation/representation is changed.
Constructors | Usage |
---|---|
OperatorConverter(string[], HashSet<string>) | Initializes an instance of OperatorConverter class with injected services |
Methods | Usage |
---|---|
IsOperator(string) | check if a string is an operator |
IsBinary(string) | check if an operator is a binary operator |
IsUnary(string) | check if an operator is a unary operator |
ToValue(string) | map an operator to numeric value |
ToOperator(int) | map a numeric value to operator |