using XFEExtension.NetCore.FormatExtension;
namespace XFEExtension.NetCore.XFEChatGPT.ChatGPTInnerClass.HelperClass;
///
/// API密钥
///
/// 秘钥
/// 描述
public class ApiKey(string aPiKey, string description)
{
private static readonly char[] Separator = ['{', '}'];
///
/// APIKEY
///
public string Key { get; set; } = aPiKey;
///
/// APIKey的描述
///
public string Description { get; set; } = description;
///
/// 转换为字符串
///
///
public override string ToString() => $"{{[+-{Description}-+][+-{Key}-+]}}";
///
/// 将字符串转换为ApiKey的List
///
///
///
public static List ToApiKey(string keyString)
{
var keyGroup = keyString.Split(Separator);
List apiKeys = [];
apiKeys.AddRange(from key in keyGroup select key.Split(XFEDictionary.EntrySeparator, StringSplitOptions.RemoveEmptyEntries) into oneKey where oneKey.Length == 2 select new ApiKey(oneKey[1], oneKey[0]));
return apiKeys;
}
}