This repository has been archived by the owner on May 23, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 12
/
Copy pathConfigEntrySource.cs
66 lines (60 loc) · 2.2 KB
/
ConfigEntrySource.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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
// -----------------------------------------------------------------------
// <copyright file="DockerBootstrap.cs" company="Petabridge, LLC">
// Copyright (C) 2018 - 2018 Petabridge, LLC <https://petabridge.com>
// </copyright>
// -----------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Linq;
namespace Akka.Bootstrap.Docker
{
/// <summary>
/// Defines a source of configuration to be evaluated and applied
/// against a HOCON key/value pair.
/// </summary>
public abstract class ConfigEntrySource
{
/// <summary>
/// Override to describe the implementation type
/// </summary>
/// <value></value>
public abstract string SourceName { get; }
/// <summary>
/// The series of key nodes which make up the path
/// </summary>
/// <value></value>
public string[] Nodes { get; }
/// <summary>
/// The full HOCON path for the given value (Derived from `Nodes`)
/// </summary>
/// <value></value>
public string Key { get; }
/// <summary>
/// The value for this given HOCON node
/// </summary>
/// <value></value>
public string Value { get; }
/// <summary>
/// Identifies if the source is a series of values
/// </summary>
public int Index { get; }
/// <summary>
/// Returns the depth of the hocon key (ie. number of nodes on the key)
/// </summary>
public int Depth => Nodes.Length;
/// <summary>
/// Creates a config entry source from a set of nodes, value and optional index
/// </summary>
/// <param name="nodes">Set of nodes which comprise the path</param>
/// <param name="value">Value stored in this entry</param>
/// <param name="index">Provided index to identify a set of hocon values stored
/// against a single key</param>
protected ConfigEntrySource(string[] nodes, string value, int index = 0)
{
Nodes = nodes;
Key = String.Join(".", Nodes);
Index = index;
Value = value;
}
}
}