csharp-sdk-upm/Storage/LCApplication.cs

59 lines
1.7 KiB
C#
Raw Normal View History

2020-02-19 18:50:51 +08:00
using System;
2020-03-10 16:25:46 +08:00
using LeanCloud.Common;
using LeanCloud.Storage;
2020-02-19 18:50:51 +08:00
using LeanCloud.Storage.Internal.Http;
namespace LeanCloud {
/// <summary>
/// LeanCloud 全局接口
/// </summary>
2020-03-10 16:25:46 +08:00
public class LCApplication {
2020-02-19 18:50:51 +08:00
// SDK 版本号,用于 User-Agent 统计
2020-03-09 12:47:07 +08:00
internal const string SDKVersion = "0.2.2";
2020-02-19 18:50:51 +08:00
// 接口版本号,用于接口版本管理
internal const string APIVersion = "1.1";
2020-03-10 16:25:46 +08:00
public static string AppId {
get; private set;
}
public static string AppKey {
get; private set;
}
2020-02-19 18:50:51 +08:00
public static bool UseProduction {
get; set;
}
2020-03-10 16:25:46 +08:00
public static LCAppRouter AppRouter {
get; private set;
}
public static LCHttpClient HttpClient {
2020-02-19 18:50:51 +08:00
get; private set;
}
public static void Initialize(string appId, string appKey, string server = null) {
if (string.IsNullOrEmpty(appId)) {
throw new ArgumentException(nameof(appId));
}
if (string.IsNullOrEmpty(appKey)) {
throw new ArgumentException(nameof(appKey));
}
2020-03-10 16:25:46 +08:00
AppId = appId;
AppKey = appKey;
// 注册 LeanCloud 内部子类化类型
LCObject.RegisterSubclass(LCUser.CLASS_NAME, () => new LCUser());
LCObject.RegisterSubclass(LCRole.CLASS_NAME, () => new LCRole());
LCObject.RegisterSubclass(LCFile.CLASS_NAME, () => new LCFile());
2020-02-19 18:50:51 +08:00
2020-03-10 16:25:46 +08:00
AppRouter = new LCAppRouter(appId, server);
2020-02-19 18:50:51 +08:00
HttpClient = new LCHttpClient(appId, appKey, server, SDKVersion, APIVersion);
}
}
}