Common console cleaned
This commit is contained in:
@@ -1,72 +1,9 @@
|
||||
namespace CommonConsole
|
||||
{
|
||||
using Newtonsoft.Json;
|
||||
using Newtonsoft.Json.Converters;
|
||||
|
||||
using System.Globalization;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
|
||||
public class Program
|
||||
{
|
||||
public static void Main(string[] args)
|
||||
{
|
||||
var content = File.ReadAllText("../../configuration.json");
|
||||
var configuration = JsonConvert.DeserializeObject<ConfigurationJson>(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];
|
||||
}
|
||||
|
||||
configuration[sectionId][registerId][version].Unit = Unit.MessurementUnits.FirstOrDefault() ?? nameof(Volume);
|
||||
|
||||
var unit = configuration[sectionId][registerId][version][nameof(Unit)];
|
||||
|
||||
if (unit is null)
|
||||
{
|
||||
configuration[sectionId][registerId][version][nameof(Unit)] = 1000;
|
||||
}
|
||||
|
||||
configuration[sectionId][registerId][version].Value = Value.ValueTypes.FirstOrDefault() ?? nameof(int32_t);
|
||||
|
||||
var value = configuration[sectionId][registerId][version][nameof(Value)];
|
||||
|
||||
if (value is null)
|
||||
{
|
||||
configuration[sectionId][registerId][version][nameof(Value)] = 1000;
|
||||
}
|
||||
}
|
||||
|
||||
private static JsonSerializerSettings settings => new JsonSerializerSettings
|
||||
{
|
||||
MetadataPropertyHandling = MetadataPropertyHandling.Ignore,
|
||||
DateParseHandling = DateParseHandling.None,
|
||||
Converters =
|
||||
{
|
||||
new AccessConverter(),
|
||||
new IsoDateTimeConverter
|
||||
{
|
||||
DateTimeStyles = DateTimeStyles.AssumeUniversal
|
||||
}
|
||||
},
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user