alielie
2026-09-10 f3889f2d36c50cf99468594854def9b7ed069fb5
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
using OpenTap.Addin.Util;
using System.Collections.Concurrent;
 
namespace OpenTap.Addin
{
    public class FileGlobalsContext
    {
        ConcurrentDictionary<string, RuntimeVariable> map = new ConcurrentDictionary<string, RuntimeVariable>();
 
        public RuntimeVariable GetFileGlobals(TestPlan plan, TestPlanRun run)
        {
            string path = plan.VisualPath;
            if (!map.ContainsKey(path))
            {
                var runtimeVariablePool = new ConcurrentDictionary<string, RuntimeVariable>();
                foreach (var data in plan.Variables)
                {
                    RuntimeVariable runTime = data.ToRuntime(run);
                    if (runTime is null) continue;
                    runtimeVariablePool[runTime.__name___] = runTime;
                }
                map[path] = new RuntimeVariable(run, ConstNames.FileGlobalsName, runtimeVariablePool);
            }
            return map[path];
        }
    }
}