56 lines
1.9 KiB
C#
56 lines
1.9 KiB
C#
namespace CommonConsole
|
|
{
|
|
using Newtonsoft.Json;
|
|
using Newtonsoft.Json.Converters;
|
|
|
|
using System.Globalization;
|
|
using System.IO;
|
|
|
|
public class Program
|
|
{
|
|
public static void Main(string[] args)
|
|
{
|
|
var content = File.ReadAllText("../../configuration.json");
|
|
var configuration = JsonConvert.DeserializeObject<JsonConfiguration>(content);
|
|
|
|
byte sectionId = 10;
|
|
byte registerId = 2;
|
|
int version = 20;
|
|
|
|
/// Getting application section from the configuration
|
|
var sectionById = configuration[sectionId];
|
|
|
|
if (!string.IsNullOrWhiteSpace(sectionById.Name))
|
|
{
|
|
/// ??? When requested by name creates new Section if name not exists in the keys collection.
|
|
var sectionByName = configuration[sectionById.Name];
|
|
}
|
|
|
|
/// Geting register by sectionId and registerId
|
|
var registerById = configuration[sectionId][registerId];
|
|
|
|
if (!string.IsNullOrWhiteSpace(registerById.Name))
|
|
{
|
|
/// ??? When requested by name creates new Register for the section if name not exists in the keys collection.
|
|
var registerByName = configuration[sectionId][registerById.Name];
|
|
}
|
|
|
|
var valueByV = configuration[sectionId][registerId][version];
|
|
}
|
|
|
|
private static JsonSerializerSettings settings => new JsonSerializerSettings
|
|
{
|
|
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
|
|
DateParseHandling = DateParseHandling.None,
|
|
Converters =
|
|
{
|
|
new AccessConverter(),
|
|
new IsoDateTimeConverter
|
|
{
|
|
DateTimeStyles = DateTimeStyles.AssumeUniversal
|
|
}
|
|
},
|
|
};
|
|
}
|
|
}
|