@@ -56,7 +56,7 @@ public partial class ExpressionEvaluator
56
56
protected static readonly Regex functionArgKeywordsRegex = new Regex ( @"^\s*(?<keyword>out|ref|in)\s+((?<typeName>[\p{L}_][\p{L}_0-9\.\[\]<>]*[?]?)\s+(?=[\p{L}_]))?(?<toEval>(?<varName>[\p{L}_](?>[\p{L}_0-9]*))\s*(=.*)?)$" , RegexOptions . Compiled | RegexOptions . IgnoreCase ) ;
57
57
58
58
protected static readonly Regex instanceCreationWithNewKeywordRegex = new Regex ( @"^new(?>\s*)((?<isAnonymous>[{{])|((?<name>[\p{L}_][\p{L}_0-9\.]*)(?>\s*)(?<isgeneric>[<](?>[^<>]+|(?<gentag>[<])|(?<-gentag>[>]))*(?(gentag)(?!))[>])?(?>\s*)((?<isfunction>[(])|(?<isArray>\[)|(?<isInit>[{{]))?))" , RegexOptions . IgnoreCase | RegexOptions . Compiled ) ;
59
- protected string CastRegexPattern { get { return @"^\((?>\s*)(?<typeName>[\p{L}_][\p{L}_0-9" + ( OptionInlineNamespacesEvaluationActive ? @"\." : string . Empty ) + @" \[\]<>]*[?]?)(?>\s*)\)"; } }
59
+ protected string CastRegexPattern { get { return @"^\((?>\s*)(?<typeName>[\p{L}_][\p{L}_0-9\. \[\]<>]*[?]?)(?>\s*)\)" ; } }
60
60
61
61
// To remove comments in scripts based on https://stackoverflow.com/questions/3524317/regex-to-strip-line-comments-from-c-sharp/3524689#3524689
62
62
protected const string blockComments = @"/\*(.*?)\*/" ;
@@ -1641,7 +1641,8 @@ protected virtual bool EvaluateCast(string expression, Stack<object> stack, ref
1641
1641
{
1642
1642
string typeName = castMatch . Groups [ "typeName" ] . Value ;
1643
1643
1644
- Type type = GetTypeByFriendlyName ( typeName ) ;
1644
+ int typeIndex = 0 ;
1645
+ Type type = EvaluateType ( typeName , ref typeIndex ) ;
1645
1646
1646
1647
if ( type != null )
1647
1648
{
@@ -4006,6 +4007,10 @@ protected static object ChangeType(object value, Type conversionType)
4006
4007
NullableConverter nullableConverter = new NullableConverter ( conversionType ) ;
4007
4008
conversionType = nullableConverter . UnderlyingType ;
4008
4009
}
4010
+ if ( conversionType . IsEnum )
4011
+ {
4012
+ return Enum . ToObject ( conversionType , value ) ;
4013
+ }
4009
4014
return Convert . ChangeType ( value , conversionType ) ;
4010
4015
}
4011
4016
0 commit comments