@@ -56,7 +56,7 @@ public partial class ExpressionEvaluator
5656 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 ) ;
5757
5858 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*)\)" ; } }
6060
6161 // To remove comments in scripts based on https://stackoverflow.com/questions/3524317/regex-to-strip-line-comments-from-c-sharp/3524689#3524689
6262 protected const string blockComments = @"/\*(.*?)\*/" ;
@@ -1641,7 +1641,8 @@ protected virtual bool EvaluateCast(string expression, Stack<object> stack, ref
16411641 {
16421642 string typeName = castMatch . Groups [ "typeName" ] . Value ;
16431643
1644- Type type = GetTypeByFriendlyName ( typeName ) ;
1644+ int typeIndex = 0 ;
1645+ Type type = EvaluateType ( typeName , ref typeIndex ) ;
16451646
16461647 if ( type != null )
16471648 {
@@ -4006,6 +4007,10 @@ protected static object ChangeType(object value, Type conversionType)
40064007 NullableConverter nullableConverter = new NullableConverter ( conversionType ) ;
40074008 conversionType = nullableConverter . UnderlyingType ;
40084009 }
4010+ if ( conversionType . IsEnum )
4011+ {
4012+ return Enum . ToObject ( conversionType , value ) ;
4013+ }
40094014 return Convert . ChangeType ( value , conversionType ) ;
40104015 }
40114016
0 commit comments