File tree Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Expand file tree Collapse file tree 1 file changed +34
-0
lines changed Original file line number Diff line number Diff line change @@ -94,5 +94,39 @@ public static NamedAttributeArgumentAst GetSupportsShouldProcessAst(this Attribu
94
94
95
95
return null ;
96
96
}
97
+
98
+ public static bool IsTrue ( this NamedAttributeArgumentAst attrAst , out ExpressionAst argumentAst )
99
+ {
100
+ argumentAst = null ;
101
+ if ( attrAst . ExpressionOmitted )
102
+ {
103
+ return true ;
104
+ }
105
+
106
+ var varExpAst = attrAst . Argument as VariableExpressionAst ;
107
+ argumentAst = attrAst . Argument ;
108
+ if ( varExpAst == null )
109
+ {
110
+ var constExpAst = attrAst . Argument as ConstantExpressionAst ;
111
+ if ( constExpAst == null )
112
+ {
113
+ return false ;
114
+ }
115
+
116
+ bool constExpVal ;
117
+ if ( LanguagePrimitives . TryConvertTo ( constExpAst . Value , out constExpVal ) )
118
+ {
119
+ return constExpVal ;
120
+ }
121
+ }
122
+ else
123
+ {
124
+ return varExpAst . VariablePath . UserPath . Equals (
125
+ bool . TrueString ,
126
+ StringComparison . OrdinalIgnoreCase ) ;
127
+ }
128
+
129
+ return false ;
130
+ }
97
131
}
98
132
}
You can’t perform that action at this time.
0 commit comments