ASCU_ALL/ApiServer/Parametrs/Metrics.cs

58 lines
1.2 KiB
C#
Raw Permalink Normal View History

2024-09-22 04:27:05 +05:00
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Threading.Tasks;
using ApiServer.Parametrs;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
namespace ApiServer.Parametrs
{
public class Metric
{
public string Name { get; set; }
public bool Log { get; set; }
}
}
namespace ApiServer
{
public static partial class Configuration
{
public static Metric[] GetMetricsArray()
{
var result = new List<Metric>();
var json_conf =
JObject.Parse(
File.ReadAllText(
Path.Combine(
Directory.GetCurrentDirectory(),
"Config",
"Metrics.json"
)
)
);
var list_objects = json_conf.GetEnumerator();
while (list_objects.MoveNext())
{
try
{
var name = list_objects.Current.Key;
var log = (bool)list_objects.Current.Value;
if (result.FindIndex(x => x.Name == name) == -1)
result.Add(new Metric()
{
Name = name,
Log = log
});
}
catch
{
continue;
}
}
return result.ToArray();
}
}
}