-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathExtensions.cs
33 lines (27 loc) · 1 KB
/
Extensions.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
using System.Linq;
using Akka.Configuration.Hocon;
using Akka.Util.Internal;
namespace Akka.Discovery.Azure;
public static class Extensions
{
internal static Configuration.Config MoveTo(this Configuration.Config config, string path)
{
var rootObj = new HoconObject();
var rootValue = new HoconValue();
rootValue.Values.Add(rootObj);
var lastObject = rootObj;
var keys = path.SplitDottedPathHonouringQuotes().ToArray();
for (var i = 0; i < keys.Length - 1; i++)
{
var key = keys[i];
var innerObject = new HoconObject();
var innerValue = new HoconValue();
innerValue.Values.Add(innerObject);
lastObject.GetOrCreateKey(key);
lastObject.Items[key] = innerValue;
lastObject = innerObject;
}
lastObject.Items[keys[keys.Length - 1]] = config.Root;
return new Configuration.Config(new HoconRoot(rootValue));
}
}