框架更新

This commit is contained in:
Bob.Song
2025-10-29 17:59:43 +08:00
parent fc18c8626a
commit a2cb248512
429 changed files with 7173 additions and 38748 deletions

View File

@@ -113,82 +113,5 @@ namespace Fantasy.ConfigTable
return types;
}
// private static string _configTableBinaryDirectory;
// private static readonly object Lock = new object();
// // 配置表数据缓存字典
// private static readonly Dictionary<string, ASerialize> ConfigDic = new ();
// /// <summary>
// /// 初始化ConfigTableHelper
// /// </summary>
// /// <param name="configTableBinaryDirectory"></param>
// public static void Initialize(string configTableBinaryDirectory)
// {
// _configTableBinaryDirectory = configTableBinaryDirectory;
// }
// /// <summary>
// /// 加载配置表数据
// /// </summary>
// /// <typeparam name="T">配置表类型</typeparam>
// /// <returns>配置表数据</returns>
// public static T Load<T>() where T : ASerialize
// {
// lock (Lock)
// {
// try
// {
// var dataConfig = typeof(T).Name;
//
// if (ConfigDic.TryGetValue(dataConfig, out var aProto))
// {
// return (T)aProto;
// }
//
// var configFile = GetConfigPath(dataConfig);
// var bytes = File.ReadAllBytes(configFile);
// // Log.Debug($"dataConfig:{dataConfig} {bytes.Length}");
// var data = SerializerManager.GetSerializer(FantasySerializerType.ProtoBuf).Deserialize<T>(bytes);
// ConfigDic[dataConfig] = data;
// return data;
// }
// catch (Exception ex)
// {
// throw new Exception($"ConfigTableManage:{typeof(T).Name} 数据表加载之后反序列化时出错:{ex}");
// }
// }
// }
//
// /// <summary>
// /// 获取配置表文件路径
// /// </summary>
// /// <param name="name">配置表名称</param>
// /// <returns>配置表文件路径</returns>
// private static string GetConfigPath(string name)
// {
// var configFile = Path.Combine(_configTableBinaryDirectory, $"{name}.bytes");
//
// if (File.Exists(configFile))
// {
// return configFile;
// }
//
// throw new FileNotFoundException($"{name}.byte not found: {configFile}");
// }
//
// /// <summary>
// /// 重新加载配置表数据
// /// </summary>
// public static void ReLoadConfigTable()
// {
// lock (Lock)
// {
// foreach (var (_, aProto) in ConfigDic)
// {
// ((IDisposable) aProto).Dispose();
// }
//
// ConfigDic.Clear();
// }
// }
}
}

View File

@@ -0,0 +1,33 @@
using System.Collections.Generic;
using ProtoBuf;
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
// ReSharper disable CheckNamespace
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
namespace Fantasy.ConfigTable
{
[ProtoContract]
public partial class IntDictionaryConfig
{
[ProtoMember(1)]
public Dictionary<int, int> Dic;
public int this[int key] => GetValue(key);
public bool TryGetValue(int key, out int value)
{
value = default;
if (!Dic.ContainsKey(key))
{
return false;
}
value = Dic[key];
return true;
}
private int GetValue(int key)
{
return Dic.TryGetValue(key, out var value) ? value : 0;
}
}
}

View File

@@ -0,0 +1,35 @@
using System.Collections.Generic;
using ProtoBuf;
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
// ReSharper disable CheckNamespace
// ReSharper disable CollectionNeverUpdated.Global
#pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable.
#pragma warning disable CS8625 // Cannot convert null literal to non-nullable reference type.
#pragma warning disable CS8603 // Possible null reference return.
namespace Fantasy.ConfigTable
{
[ProtoContract]
public sealed partial class StringDictionaryConfig
{
[ProtoMember(1)]
public Dictionary<int, string> Dic;
public string this[int key] => GetValue(key);
public bool TryGetValue(int key, out string value)
{
value = default;
if (!Dic.ContainsKey(key))
{
return false;
}
value = Dic[key];
return true;
}
private string GetValue(int key)
{
return Dic.TryGetValue(key, out var value) ? value : null;
}
}
}

View File

@@ -24,7 +24,7 @@
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Fantasy-Net" Version="2024.2.22" />
<ProjectReference Include="..\..\..\Fantasy.Net\Fantasy.Net\Fantasy.Net.csproj" />
</ItemGroup>
<ItemGroup>