chr
2026-04-08 53e656200368a983e563550e2cc1acbc6d86b729
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
using System.Collections.Concurrent;
 
namespace OpenTap.Addin
{
    public class FileGlobalsContext
    {
        ConcurrentDictionary<string, VariableContext> map = new ConcurrentDictionary<string, VariableContext>();
 
        public VariableContext GetFileGlobals(TestPlan plan)
        {
            string path = plan.VisualPath;
            if (!map.ContainsKey(path))
            {
                var runtimeVariablePool = new ConcurrentDictionary<string, RuntimeVariable>();
                foreach (var data in plan.Variables)
                {
                    RuntimeVariable runTime = data.ToRuntime();
                    if (runTime == null) continue;
                    runtimeVariablePool[runTime.Name] = runTime;
                }
                map[path] = new VariableContext(runtimeVariablePool);
            }
            return map[path];
        }
    }
}