-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathEnvVarsReplacer.cs
42 lines (36 loc) · 1005 Bytes
/
EnvVarsReplacer.cs
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
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.Collections.Generic;
using Newtonsoft.Json.Linq;
namespace akash_dep
{
public class EnvVarsReplacer
{
Dictionary<String, String> m_evaluated = new Dictionary<string, string>();
public String Prepare(String val)
{
foreach (var eval in m_evaluated)
{
val = val.Replace("$" + eval.Key, eval.Value);
}
return val;
}
public void Add(String key, String val)
{
val = val.Replace("\n", "");
m_evaluated[key] = val;
}
public void Evaluate(String key, String value)
{
value = Prepare(value); // replace with known values
Akash.Push("echo " + value);
Add(key, Akash.Send());
}
public void Print()
{
foreach (var eval in m_evaluated)
{
Console.WriteLine(eval.Key + "=" + eval.Value);
}
}
}
}