Files
Pal3.Unity/Assets/Scripts/Pal3/Command/CommandExtensions.cs
T
Jackie Liu 3b62ced28c Implement simple save system
Implement simple save system
2022-10-02 16:11:26 -07:00

33 lines
1.1 KiB
C#

// ---------------------------------------------------------------------------------------------
// Copyright (c) 2021-2022, Jiaqi Liu. All rights reserved.
// See LICENSE file in the project root for license information.
// ---------------------------------------------------------------------------------------------
namespace Pal3.Command
{
using System;
using System.Reflection;
using System.Text;
public static class CommandExtensions
{
public static string ToString(ICommand command)
{
var builder = new StringBuilder();
Type type = command.GetType();
builder.Append(type.Name[..^"Command".Length]);
builder.Append(' ');
foreach (PropertyInfo propertyInfo in type.GetProperties())
{
builder.Append(propertyInfo.GetValue(command));
builder.Append(' ');
}
var commandStr = builder.ToString();
if (commandStr.EndsWith(' ')) commandStr = commandStr[..^1];
return commandStr;
}
}
}