mirror of
https://git.lewd.wtf/PGR/ascnet
synced 2025-12-12 22:34:38 +01:00
config.tab
This commit is contained in:
@@ -19,6 +19,9 @@ namespace AscNet.Common
|
||||
|
||||
interface IGameServer
|
||||
{
|
||||
[Option(DefaultValue = nameof(AscNet))]
|
||||
string RegionName { get; set; }
|
||||
|
||||
[Option(DefaultValue = "127.0.0.1")]
|
||||
string Host { get; set; }
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ namespace AscNet.Common.Util
|
||||
{
|
||||
public class Logger
|
||||
{
|
||||
public static readonly Logger c = new("SF", ConsoleColor.DarkRed);
|
||||
public static readonly Logger c = new(nameof(AscNet), ConsoleColor.DarkRed);
|
||||
private readonly string _name;
|
||||
private readonly bool TraceOnError;
|
||||
private readonly ConsoleColor _color;
|
||||
|
||||
37
AscNet.Common/Util/TsvTool.cs
Normal file
37
AscNet.Common/Util/TsvTool.cs
Normal file
@@ -0,0 +1,37 @@
|
||||
using System.Reflection;
|
||||
|
||||
namespace AscNet.Common.Util
|
||||
{
|
||||
public static class TsvTool
|
||||
{
|
||||
public static string SerializeObject<T>(IEnumerable<T> objs) where T : new()
|
||||
{
|
||||
string res = string.Empty;
|
||||
|
||||
Type type = typeof(T);
|
||||
var properties = type.GetProperties()
|
||||
.OrderBy(p => p.GetCustomAttribute<PropertyOrderAttribute>()?.Order ?? int.MaxValue)
|
||||
.ToList();
|
||||
|
||||
res += string.Join('\t', properties.Select(x => x.Name)) + '\n';
|
||||
|
||||
foreach (var obj in objs)
|
||||
{
|
||||
res += string.Join('\t', properties.Select(x => x.GetValue(obj))) + '\n';
|
||||
}
|
||||
|
||||
return res;
|
||||
}
|
||||
}
|
||||
|
||||
[AttributeUsage(AttributeTargets.Property, Inherited = false, AllowMultiple = false)]
|
||||
public sealed class PropertyOrderAttribute : Attribute
|
||||
{
|
||||
public int Order { get; }
|
||||
|
||||
public PropertyOrderAttribute(int order)
|
||||
{
|
||||
Order = order;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user