초기커밋

This commit is contained in:
2025-05-01 07:20:41 +09:00
commit 98bb2e3c5c
2747 changed files with 646947 additions and 0 deletions

View File

@@ -0,0 +1,51 @@
using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
namespace ServerBase;
public static class ContentLoader
{
public static T? loadFile<T>(string dataDir, string fileName) where T : ContentTableBase<T>
{
try
{
string exactPath = Path.GetFullPath(dataDir);
string data = File.ReadAllText(Path.Combine(dataDir, fileName));
return Newtonsoft.Json.JsonConvert.DeserializeObject<T>(data);
}
catch (Exception ex)
{
throw new Exception($"content load fail. dataDir: {dataDir}, fileName: {fileName}", ex);
}
}
public static T? loadMultipleFiles<T>(string dataDir, string filePattern) where T : ContentTableBase<T>
{
var files = Directory.GetFiles(dataDir, filePattern, SearchOption.TopDirectoryOnly);
List<T> tables = new List<T>();
foreach (string file in files)
{
string data = File.ReadAllText(file);
T? json = Newtonsoft.Json.JsonConvert.DeserializeObject<T>(data);
if (json != null)
tables.Add(json);
}
T? oneTable = null;
foreach (var table in tables)
{
if (oneTable == null)
oneTable = table;
else
oneTable.merge(table);
}
return oneTable;
}
}

View File

@@ -0,0 +1,11 @@
using System;
using System.Collections.Generic;
using System.Text;
namespace ServerBase;
public class ContentTableBase<T>
{
public virtual void merge(T table) { }
}

View File

@@ -0,0 +1,8 @@

namespace ServerBase;
public interface IMetaData
{
string toBasicString();
}