public object?ConvertToDesiredType(object?evaluationResult, Type desiredType) { if (evaluationResult is null) { return(null); } return(_wrapped.ConvertToDesiredType(evaluationResult, desiredType)); }
public object?ConvertToDesiredType(object?evaluationResult, Type desiredType) { if (evaluationResult is IEnumerable enumerable && !(evaluationResult is ExpandoObject)) { return(ConvertEnumerable(enumerable, desiredType)); } return(wrapped?.ConvertToDesiredType(evaluationResult, desiredType)); }
public object?ConvertToDesiredType(object?evaluationResult, Type desiredType) { if (evaluationResult is ExpandoObject expando && desiredType == typeof(object)) { return(RecursivelyPrepareExpandoObjectForReturn(expando)); } return(wrapped.ConvertToDesiredType(evaluationResult, desiredType)); }
public object?ConvertToDesiredType(object?evaluationResult, Type desiredType) { var converter = TypeDescriptor.GetConverter(evaluationResult); if (converter.CanConvertTo(desiredType)) { return(converter.ConvertTo(evaluationResult, desiredType)); } return(wrapped.ConvertToDesiredType(evaluationResult, desiredType)); }
public async Task <object?> EvaluateAsync( string expression, Type returnType, ActivityExecutionContext context, Action <Engine>?configureEngine = default, CancellationToken cancellationToken = default) { var engine = await GetConfiguredEngine(configureEngine, context, cancellationToken); var result = ExecuteExpressionAndGetResult(engine, expression); return(_resultConverter.ConvertToDesiredType(result, returnType)); }
public object?ConvertToDesiredType(object?evaluationResult, Type desiredType) { if (desiredType == typeof(object)) { return(evaluationResult); } if (evaluationResult.GetType() == desiredType || desiredType.IsAssignableFrom(evaluationResult.GetType())) { return(evaluationResult); } return(wrapped.ConvertToDesiredType(evaluationResult, desiredType)); }
public object?ConvertToDesiredType(object?evaluationResult, Type desiredType) { if (evaluationResult is ExpandoObject expando) { if (desiredType == typeof(object)) { return(RecursivelyPrepareExpandoObjectForReturn(expando)); } var serializationSettings = new JsonSerializerSettings().ConfigureForNodaTime(DateTimeZoneProviders.Tzdb); var json = JsonConvert.SerializeObject(evaluationResult, desiredType, serializationSettings); return(JsonConvert.DeserializeObject(json, desiredType, serializationSettings)); } return(_wrapped.ConvertToDesiredType(evaluationResult, desiredType)); }
public object?ConvertToDesiredType(object?evaluationResult, Type desiredType) { var converter = TypeDescriptor.GetConverter(evaluationResult !); if (converter.CanConvertTo(desiredType)) { return(converter.ConvertTo(evaluationResult !, desiredType)); } var targetConverter = TypeDescriptor.GetConverter(desiredType); if (targetConverter.CanConvertFrom(evaluationResult !.GetType())) { return(targetConverter.ConvertFrom(evaluationResult !)); } return(wrapped.ConvertToDesiredType(evaluationResult, desiredType)); }
public object?ConvertToDesiredType(object?evaluationResult, Type desiredType) { if (evaluationResult == null) { return(null); } if (desiredType == typeof(object)) { return(evaluationResult); } if (evaluationResult.GetType() == desiredType || desiredType.IsInstanceOfType(evaluationResult)) { return(evaluationResult); } return(_wrapped.ConvertToDesiredType(evaluationResult, desiredType)); }
public object?ConvertToDesiredType(object?evaluationResult, Type desiredType) { var valueToConvert = evaluationResult is IListSource listSource?listSource.GetList() : evaluationResult; return(_wrapped.ConvertToDesiredType(valueToConvert, desiredType)); }