f265d74730
- aggiunto conf YAML x default
51 lines
1.5 KiB
C#
51 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Xml.Linq;
|
|
using YamlDotNet.Serialization.NamingConventions;
|
|
using YamlDotNet.Serialization;
|
|
using System.Reflection.Metadata;
|
|
|
|
namespace ConfMan.IOB.CApp
|
|
{
|
|
public class CAConf
|
|
{
|
|
public string ConfDir { get; set; } = "";
|
|
public string Customer { get; set; } = "";
|
|
public string FileType { get; set; } = "";
|
|
public string OS { get; set; } = "";
|
|
|
|
public CAConf()
|
|
{
|
|
this.FileType = ".ini";
|
|
this.ConfDir = @"C:\Steamware\IOB-WIN-NEXT\DATA\CONF";
|
|
this.Customer = "ACME";
|
|
this.OS = "WIN";
|
|
}
|
|
}
|
|
public class CMan
|
|
{
|
|
/// <summary>
|
|
/// Deserializza dato filePath
|
|
/// </summary>
|
|
/// <param name="filePath"></param>
|
|
public static CAConf readConf(string filePath)
|
|
{
|
|
CAConf retObj = new CAConf();
|
|
if (File.Exists(filePath))
|
|
{
|
|
var deserializer = new DeserializerBuilder()
|
|
.WithNamingConvention(new PascalCaseNamingConvention())
|
|
.Build();
|
|
string rawData = File.ReadAllText(filePath);
|
|
|
|
var input = new StringReader(rawData);
|
|
retObj = deserializer.Deserialize<CAConf>(input);
|
|
}
|
|
return retObj;
|
|
}
|
|
}
|
|
}
|