49 lines
1.7 KiB
C#
49 lines
1.7 KiB
C#
using System.Reflection;
|
|
|
|
internal class Program
|
|
{
|
|
private static void Main(string[] args)
|
|
{
|
|
var conf = new Ini("./conf.ini");
|
|
var assemblyPath = conf.GetValue("assembly");
|
|
Assembly assembly = Assembly.LoadFile(Path.GetFullPath(assemblyPath));
|
|
var classType = assembly.GetType("GConstant");
|
|
if(classType != null)
|
|
{
|
|
var fields = classType.GetFields(
|
|
System.Reflection.BindingFlags.Public |
|
|
System.Reflection.BindingFlags.Static);
|
|
|
|
if(fields.Length == 0) return;
|
|
|
|
SimpleJSON.JSONNode configJson = new SimpleJSON.JSONObject();
|
|
bool isFullConfig = args.Contains("--full");
|
|
|
|
foreach(var f in fields)
|
|
{
|
|
var fieldName = f.Name;
|
|
if(fieldName.StartsWith("K_"))
|
|
{
|
|
var confValue = conf.GetValue(fieldName, "Unity");
|
|
if(!string.IsNullOrEmpty(confValue) || isFullConfig)
|
|
{
|
|
#pragma warning disable CS8600,CS8604
|
|
var prop = (string) f.GetValue(null);
|
|
configJson[prop] =
|
|
string.IsNullOrEmpty(confValue) ?
|
|
"< Replace With Your Value >" : confValue;
|
|
#pragma warning restore CS8600,CS8604
|
|
}
|
|
}
|
|
}
|
|
|
|
if(!configJson.IsNull)
|
|
{
|
|
var configFilePath = conf.GetValue("ConfigPath");
|
|
if(System.IO.File.Exists(configFilePath)) System.IO.File.Delete(configFilePath);
|
|
System.IO.File.WriteAllText(configFilePath, configJson.ToString(4));
|
|
}
|
|
}
|
|
}
|
|
}
|