File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ namespace BooleanExpressionParser ;
2+
3+ class ExpressionWrapper
4+ {
5+ public string Expression { get ; private set ; }
6+ public string [ ] VariableOrder { get ; private set ; }
7+
8+ public ExpressionWrapper ( string input )
9+ {
10+ input = input . Trim ( ) ;
11+ var parts = input . Split ( ';' ) ;
12+ for ( int i = 0 ; i < parts . Length ; i ++ )
13+ {
14+ parts [ i ] = parts [ i ] . Trim ( ) ;
15+ }
16+
17+ if ( input . Length == 0 ) throw new ArgumentException ( "Expression cannot be empty" , nameof ( input ) ) ;
18+ if ( parts [ 0 ] . Length == 0 ) throw new ArgumentException ( "Expression cannot be empty" , nameof ( input ) ) ;
19+
20+ Expression = parts [ 0 ] ;
21+
22+ if ( parts . Length > 1 && parts [ 1 ] . Length != 0 )
23+ {
24+ VariableOrder = parts [ 1 ] . Split ( ',' ) ;
25+ for ( int i = 0 ; i < VariableOrder . Length ; i ++ )
26+ {
27+ VariableOrder [ i ] = VariableOrder [ i ] . Trim ( ) ;
28+ }
29+ }
30+ else {
31+ VariableOrder = new string [ 0 ] ;
32+ }
33+
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments