namespace Yw
|
{
|
/// <summary>
|
/// 调用入口
|
/// </summary>
|
public sealed partial class BIMFaceClient
|
{
|
/// <summary>
|
/// 获取BimfaceClient对象
|
/// </summary>
|
public static BIMFaceClient Instance(string appKey, string appSecret)
|
{
|
var client = _clients.Find(x => x.AppKey == appKey && x.AppSecret == appSecret);
|
if (client == null)
|
{
|
lock (_locker)
|
{
|
client = _clients.Find(x => x.AppKey == appKey && x.AppSecret == appSecret);
|
if (client == null)
|
{
|
client = new BIMFaceClient(appKey, appSecret);
|
_clients.Add(client);
|
}
|
}
|
}
|
return client;
|
}
|
|
//私有构造函数
|
private BIMFaceClient(string AppKey, string AppSecret)
|
{
|
_appKey = AppKey;
|
_appSecret = AppSecret;
|
}
|
|
/// <summary>
|
/// AppKey
|
/// </summary>
|
public string AppKey { get => _appKey; }
|
private string _appKey;
|
|
/// <summary>
|
/// AppSecret
|
/// </summary>
|
public string AppSecret { get => _appSecret; }
|
private string _appSecret;
|
|
private static object _locker = new();//锁对象
|
private static List<BIMFaceClient> _clients = new();//client 列表
|
|
|
}
|
|
}
|