@@ -78,38 +78,7 @@ public partial class ExpressionEvaluator
7878
7979 #endregion
8080
81- #region enums (Operators, if else blocks states)
82-
83- protected enum ExpressionOperator
84- {
85- Plus ,
86- Minus ,
87- UnaryPlus ,
88- UnaryMinus ,
89- Multiply ,
90- Divide ,
91- Modulo ,
92- Lower ,
93- Greater ,
94- Equal ,
95- LowerOrEqual ,
96- GreaterOrEqual ,
97- Is ,
98- NotEqual ,
99- LogicalNegation ,
100- BitwiseComplement ,
101- ConditionalAnd ,
102- ConditionalOr ,
103- LogicalAnd ,
104- LogicalOr ,
105- LogicalXor ,
106- ShiftBitsLeft ,
107- ShiftBitsRight ,
108- NullCoalescing ,
109- Cast ,
110- Indexing ,
111- IndexingWithNullConditional ,
112- }
81+ #region enums (if else blocks states)
11382
11483 private enum IfBlockEvaluatedState
11584 {
@@ -2368,7 +2337,7 @@ private bool EvaluateParenthis(string expr, string s, Stack<object> stack, ref i
23682337
23692338 private void CorrectStackWithUnaryPlusOrMinusBeforeParenthisIfNecessary ( Stack < object > stack )
23702339 {
2371- if ( stack . Count > 0 && stack . Peek ( ) is ExpressionOperator op && ( op == ExpressionOperator . Plus || stack . Peek ( ) is ExpressionOperator . Minus ) )
2340+ if ( stack . Count > 0 && stack . Peek ( ) is ExpressionOperator op && ( op == ExpressionOperator . Plus || op == ExpressionOperator . Minus ) )
23722341 {
23732342 stack . Pop ( ) ;
23742343
@@ -2643,7 +2612,7 @@ private object ProcessStack(Stack<object> stack)
26432612 {
26442613 ExpressionOperator eOp = operatorEvalutationsDict . Keys . ToList ( ) [ opi ] ;
26452614
2646- if ( ( list [ i ] as ExpressionOperator ? ) == eOp )
2615+ if ( ( list [ i ] as ExpressionOperator ) == eOp )
26472616 {
26482617 if ( rightOperandOnlyOperatorsEvaluationDictionary . ContainsKey ( eOp ) )
26492618 {
@@ -3374,7 +3343,72 @@ public enum OptionOnNoReturnKeywordFoundInScriptAction
33743343
33753344 #endregion
33763345
3377- #region ExpressionEvaluator linked public classes (specific Exceptions and EventArgs)
3346+ #region ExpressionEvaluator linked public classes (specific Exceptions, EventArgs and Operators)
3347+
3348+ public partial class ExpressionOperator : IEquatable < ExpressionOperator >
3349+ {
3350+ protected static uint indexer = 0 ;
3351+
3352+ protected ExpressionOperator ( )
3353+ {
3354+ indexer ++ ;
3355+ OperatorValue = indexer ;
3356+ }
3357+
3358+ protected ExpressionOperator ( uint value )
3359+ {
3360+ OperatorValue = value ;
3361+ }
3362+
3363+ protected uint OperatorValue { get ; }
3364+
3365+ public static readonly ExpressionOperator Plus = new ExpressionOperator ( ) ;
3366+ public static readonly ExpressionOperator Minus = new ExpressionOperator ( ) ;
3367+ public static readonly ExpressionOperator UnaryPlus = new ExpressionOperator ( ) ;
3368+ public static readonly ExpressionOperator UnaryMinus = new ExpressionOperator ( ) ;
3369+ public static readonly ExpressionOperator Multiply = new ExpressionOperator ( ) ;
3370+ public static readonly ExpressionOperator Divide = new ExpressionOperator ( ) ;
3371+ public static readonly ExpressionOperator Modulo = new ExpressionOperator ( ) ;
3372+ public static readonly ExpressionOperator Lower = new ExpressionOperator ( ) ;
3373+ public static readonly ExpressionOperator Greater = new ExpressionOperator ( ) ;
3374+ public static readonly ExpressionOperator Equal = new ExpressionOperator ( ) ;
3375+ public static readonly ExpressionOperator LowerOrEqual = new ExpressionOperator ( ) ;
3376+ public static readonly ExpressionOperator GreaterOrEqual = new ExpressionOperator ( ) ;
3377+ public static readonly ExpressionOperator Is = new ExpressionOperator ( ) ;
3378+ public static readonly ExpressionOperator NotEqual = new ExpressionOperator ( ) ;
3379+ public static readonly ExpressionOperator LogicalNegation = new ExpressionOperator ( ) ;
3380+ public static readonly ExpressionOperator BitwiseComplement = new ExpressionOperator ( ) ;
3381+ public static readonly ExpressionOperator ConditionalAnd = new ExpressionOperator ( ) ;
3382+ public static readonly ExpressionOperator ConditionalOr = new ExpressionOperator ( ) ;
3383+ public static readonly ExpressionOperator LogicalAnd = new ExpressionOperator ( ) ;
3384+ public static readonly ExpressionOperator LogicalOr = new ExpressionOperator ( ) ;
3385+ public static readonly ExpressionOperator LogicalXor = new ExpressionOperator ( ) ;
3386+ public static readonly ExpressionOperator ShiftBitsLeft = new ExpressionOperator ( ) ;
3387+ public static readonly ExpressionOperator ShiftBitsRight = new ExpressionOperator ( ) ;
3388+ public static readonly ExpressionOperator NullCoalescing = new ExpressionOperator ( ) ;
3389+ public static readonly ExpressionOperator Cast = new ExpressionOperator ( ) ;
3390+ public static readonly ExpressionOperator Indexing = new ExpressionOperator ( ) ;
3391+ public static readonly ExpressionOperator IndexingWithNullConditional = new ExpressionOperator ( ) ;
3392+
3393+ public override bool Equals ( object obj )
3394+ {
3395+ if ( obj is ExpressionOperator otherOperator )
3396+ return Equals ( otherOperator ) ;
3397+ else
3398+ return OperatorValue . Equals ( obj ) ;
3399+ }
3400+
3401+ public override int GetHashCode ( )
3402+ {
3403+ return OperatorValue . GetHashCode ( ) ;
3404+ }
3405+
3406+ public bool Equals ( ExpressionOperator otherOperator )
3407+ {
3408+ return otherOperator != null && OperatorValue == otherOperator . OperatorValue ;
3409+ }
3410+ }
3411+
33783412
33793413 public partial class ClassOrEnumType
33803414 {
@@ -3388,6 +3422,7 @@ public ExpressionEvaluatorSyntaxErrorException() : base()
33883422
33893423 public ExpressionEvaluatorSyntaxErrorException ( string message ) : base ( message )
33903424 { }
3425+
33913426 public ExpressionEvaluatorSyntaxErrorException ( string message , Exception innerException ) : base ( message , innerException )
33923427 { }
33933428 }
@@ -3399,6 +3434,7 @@ public ExpressionEvaluatorSecurityException() : base()
33993434
34003435 public ExpressionEvaluatorSecurityException ( string message ) : base ( message )
34013436 { }
3437+
34023438 public ExpressionEvaluatorSecurityException ( string message , Exception innerException ) : base ( message , innerException )
34033439 { }
34043440 }
0 commit comments