Exemple #1
0
 public static async Task ExpandValuesAsync(RompExecutionContext context)
 {
     foreach (var var in variables)
     {
         try
         {
             var.Value.value = await ExpandValueAsync(var.Value.value, context);
         }
         catch (Exception ex)
         {
             throw new ExecutionFailureException($"Error expanding variables in \"{var.Key}\" session variable: {ex.Message}");
         }
     }
 }
Exemple #2
0
        private static async Task <RuntimeValue> ExpandValueAsync(RuntimeValue value, RompExecutionContext context)
        {
            switch (value.ValueType)
            {
            case RuntimeValueType.Scalar:
                return(await context.ExpandVariablesAsync(value.AsString()));

            case RuntimeValueType.Vector:
                var list = new List <RuntimeValue>();
                foreach (var item in value.AsEnumerable())
                {
                    list.Add(await ExpandValueAsync(item, context));
                }
                return(new RuntimeValue(list));

            case RuntimeValueType.Map:
                var map = new Dictionary <string, RuntimeValue>();
                foreach (var pair in value.AsDictionary())
                {
                    map.Add(pair.Key, await ExpandValueAsync(pair.Value, context));
                }
                return(new RuntimeValue(map));

            default:
                throw new ArgumentException();
            }
        }