* AppRouterState.cs: chore: 格式化代码

* AVUser.cs:
* AVFile.cs:
* AVQuery.cs:
* AVFile.cs:
* AVCloud.cs:
* AVUser.cs:
* AVClient.cs:
* AVObject.cs:
* IAVQuery.cs:
* AVCloud.cs:
* AVObject.cs:
* AVExtensions.cs:
* AVQueryExtensions.cs:
* AVQueryExtensions.cs:
* QiniuUploader.cs:
* HttpClient.Unity.cs:
* IAVFileController.cs:
* AWSS3FileController.cs:
* IAVConfigController.cs:
* ObjectSubclassInfo.cs:
* IAVCloudCodeController.cs:
* ObjectSubclassingController.cs:
oneRain 2019-08-28 17:00:03 +08:00
parent 6a42f1f74a
commit 7a5aef733d
23 changed files with 290 additions and 517 deletions

View File

@ -46,11 +46,11 @@ namespace LeanCloud.Storage.Internal
return new AppRouterState() return new AppRouterState()
{ {
TTL = -1, TTL = -1,
ApiServer = String.Format("{0}.api.lncld.net", prefix), ApiServer = string.Format("{0}.api.lncld.net", prefix),
EngineServer = String.Format("{0}.engine.lncld.net", prefix), EngineServer = string.Format("{0}.engine.lncld.net", prefix),
PushServer = String.Format("{0}.push.lncld.net", prefix), PushServer = string.Format("{0}.push.lncld.net", prefix),
RealtimeRouterServer = String.Format("{0}.rtm.lncld.net", prefix), RealtimeRouterServer = string.Format("{0}.rtm.lncld.net", prefix),
StatsServer = String.Format("{0}.stats.lncld.net", prefix), StatsServer = string.Format("{0}.stats.lncld.net", prefix),
Source = "initial", Source = "initial",
}; };
case 1: case 1:

View File

@ -7,7 +7,7 @@ namespace LeanCloud.Storage.Internal
{ {
public interface IAVCloudCodeController public interface IAVCloudCodeController
{ {
Task<T> CallFunctionAsync<T>(String name, Task<T> CallFunctionAsync<T>(string name,
IDictionary<string, object> parameters, IDictionary<string, object> parameters,
string sessionToken, string sessionToken,
CancellationToken cancellationToken); CancellationToken cancellationToken);

View File

@ -16,6 +16,6 @@ namespace LeanCloud.Storage.Internal {
/// <returns>The config async.</returns> /// <returns>The config async.</returns>
/// <param name="sessionToken">Session token.</param> /// <param name="sessionToken">Session token.</param>
/// <param name="cancellationToken">Cancellation token.</param> /// <param name="cancellationToken">Cancellation token.</param>
Task<AVConfig> FetchConfigAsync(String sessionToken, CancellationToken cancellationToken); Task<AVConfig> FetchConfigAsync(string sessionToken, CancellationToken cancellationToken);
} }
} }

View File

@ -18,7 +18,7 @@ namespace LeanCloud.Storage.Internal
} }
public override Task<FileState> SaveAsync(FileState state, Stream dataStream, string sessionToken, IProgress<AVUploadProgressEventArgs> progress, CancellationToken cancellationToken = default(System.Threading.CancellationToken)) public override Task<FileState> SaveAsync(FileState state, Stream dataStream, string sessionToken, IProgress<AVUploadProgressEventArgs> progress, CancellationToken cancellationToken = default)
{ {
if (state.Url != null) if (state.Url != null)
{ {

View File

@ -9,7 +9,7 @@ namespace LeanCloud.Storage.Internal
{ {
Task<FileState> SaveAsync(FileState state, Task<FileState> SaveAsync(FileState state,
Stream dataStream, Stream dataStream,
String sessionToken, string sessionToken,
IProgress<AVUploadProgressEventArgs> progress, IProgress<AVUploadProgressEventArgs> progress,
CancellationToken cancellationToken); CancellationToken cancellationToken);

View File

@ -64,7 +64,7 @@ namespace LeanCloud.Storage.Internal
var statusCode = GetResponseStatusCode(request); var statusCode = GetResponseStatusCode(request);
// Returns HTTP error if that's the only info we have. // Returns HTTP error if that's the only info we have.
// if (!String.IsNullOrEmpty(www.error) && String.IsNullOrEmpty(www.text)) // if (!String.IsNullOrEmpty(www.error) && String.IsNullOrEmpty(www.text))
if (!String.IsNullOrEmpty(request.error) && String.IsNullOrEmpty(request.downloadHandler.text)) if (!string.IsNullOrEmpty(request.error) && string.IsNullOrEmpty(request.downloadHandler.text))
{ {
var errorString = string.Format("{{\"error\":\"{0}\"}}", request.error); var errorString = string.Format("{{\"error\":\"{0}\"}}", request.error);
tcs.TrySetResult(new Tuple<HttpStatusCode, string>(statusCode, errorString)); tcs.TrySetResult(new Tuple<HttpStatusCode, string>(statusCode, errorString));

View File

@ -17,7 +17,7 @@ namespace LeanCloud.Storage.Internal {
return query.ClassName; return query.ClassName;
} }
public static IDictionary<String, object> BuildParameters<T>(this AVQuery<T> query) where T: AVObject { public static IDictionary<string, object> BuildParameters<T>(this AVQuery<T> query) where T: AVObject {
return query.BuildParameters(false); return query.BuildParameters(false);
} }

View File

@ -85,17 +85,17 @@ namespace LeanCloud
/// <summary> /// <summary>
/// The build number of your app. /// The build number of your app.
/// </summary> /// </summary>
public String BuildVersion { get; set; } public string BuildVersion { get; set; }
/// <summary> /// <summary>
/// The human friendly version number of your happ. /// The human friendly version number of your happ.
/// </summary> /// </summary>
public String DisplayVersion { get; set; } public string DisplayVersion { get; set; }
/// <summary> /// <summary>
/// The operating system version of the platform the SDK is operating in.. /// The operating system version of the platform the SDK is operating in..
/// </summary> /// </summary>
public String OSVersion { get; set; } public string OSVersion { get; set; }
} }

View File

@ -181,7 +181,6 @@ namespace LeanCloud {
/// <param name="template">Sms's template</param> /// <param name="template">Sms's template</param>
/// <param name="env">Template variables env.</param> /// <param name="env">Template variables env.</param>
/// <param name="sign">Sms's sign.</param> /// <param name="sign">Sms's sign.</param>
/// <param name="cancellationToken">Cancellation token.</param>
/// <returns></returns> /// <returns></returns>
public static Task<bool> RequestSMSCodeAsync( public static Task<bool> RequestSMSCodeAsync(
string mobilePhoneNumber, string mobilePhoneNumber,
@ -200,11 +199,11 @@ namespace LeanCloud {
{ "mobilePhoneNumber", mobilePhoneNumber }, { "mobilePhoneNumber", mobilePhoneNumber },
}; };
strs.Add("template", template); strs.Add("template", template);
if (String.IsNullOrEmpty(sign)) if (string.IsNullOrEmpty(sign))
{ {
strs.Add("sign", sign); strs.Add("sign", sign);
} }
if (String.IsNullOrEmpty(validateToken)) if (string.IsNullOrEmpty(validateToken))
{ {
strs.Add("validate_token", validateToken); strs.Add("validate_token", validateToken);
} }
@ -318,7 +317,7 @@ namespace LeanCloud {
/// <returns>an instance of Captcha.</returns> /// <returns>an instance of Captcha.</returns>
public static Task<Captcha> RequestCaptchaAsync(int width = 85, int height = 30, CancellationToken cancellationToken = default) public static Task<Captcha> RequestCaptchaAsync(int width = 85, int height = 30, CancellationToken cancellationToken = default)
{ {
var path = String.Format("requestCaptcha?width={0}&height={1}", width, height); var path = string.Format("requestCaptcha?width={0}&height={1}", width, height);
var command = new AVCommand(path, "GET", null, data: null); var command = new AVCommand(path, "GET", null, data: null);
return AVPlugins.Instance.CommandRunner.RunCommandAsync(command, cancellationToken: cancellationToken).OnSuccess(t => return AVPlugins.Instance.CommandRunner.RunCommandAsync(command, cancellationToken: cancellationToken).OnSuccess(t =>
{ {

View File

@ -386,7 +386,7 @@ namespace LeanCloud
{ {
get get
{ {
String str; string str;
lock (this.mutex) lock (this.mutex)
{ {
str = state.ObjectId; str = state.ObjectId;

View File

@ -241,8 +241,7 @@ namespace LeanCloud
private static string GetFieldForPropertyName(string className, string propertyName) private static string GetFieldForPropertyName(string className, string propertyName)
{ {
String fieldName = null; SubclassingController.GetPropertyMappings(className).TryGetValue(propertyName, out string fieldName);
SubclassingController.GetPropertyMappings(className).TryGetValue(propertyName, out fieldName);
return fieldName; return fieldName;
} }

View File

@ -86,7 +86,7 @@ namespace LeanCloud
int? limit = null, int? limit = null,
IEnumerable<string> includes = null, IEnumerable<string> includes = null,
IEnumerable<string> selectedKeys = null, IEnumerable<string> selectedKeys = null,
String redirectClassNameForKey = null) string redirectClassNameForKey = null)
: base(source, where, replacementOrderBy, thenBy, skip, limit, includes, selectedKeys, redirectClassNameForKey) : base(source, where, replacementOrderBy, thenBy, skip, limit, includes, selectedKeys, redirectClassNameForKey)
{ {
@ -114,7 +114,7 @@ namespace LeanCloud
int? limit = null, int? limit = null,
IEnumerable<string> includes = null, IEnumerable<string> includes = null,
IEnumerable<string> selectedKeys = null, IEnumerable<string> selectedKeys = null,
String redirectClassNameForKey = null) string redirectClassNameForKey = null)
{ {
return new AVQuery<T>(this, where, replacementOrderBy, thenBy, skip, limit, includes, selectedKeys, redirectClassNameForKey); return new AVQuery<T>(this, where, replacementOrderBy, thenBy, skip, limit, includes, selectedKeys, redirectClassNameForKey);
} }

File diff suppressed because it is too large Load Diff

View File

@ -140,7 +140,7 @@ namespace LeanCloud
protected readonly ReadOnlyCollection<string> orderBy; protected readonly ReadOnlyCollection<string> orderBy;
protected readonly ReadOnlyCollection<string> includes; protected readonly ReadOnlyCollection<string> includes;
protected readonly ReadOnlyCollection<string> selectedKeys; protected readonly ReadOnlyCollection<string> selectedKeys;
protected readonly String redirectClassNameForKey; protected readonly string redirectClassNameForKey;
protected readonly int? skip; protected readonly int? skip;
protected readonly int? limit; protected readonly int? limit;
@ -184,7 +184,7 @@ namespace LeanCloud
int? limit = null, int? limit = null,
IEnumerable<string> includes = null, IEnumerable<string> includes = null,
IEnumerable<string> selectedKeys = null, IEnumerable<string> selectedKeys = null,
String redirectClassNameForKey = null); string redirectClassNameForKey = null);
/// <summary> /// <summary>
/// Private constructor for composition of queries. A Source query is required, /// Private constructor for composition of queries. A Source query is required,
@ -199,7 +199,7 @@ namespace LeanCloud
int? limit = null, int? limit = null,
IEnumerable<string> includes = null, IEnumerable<string> includes = null,
IEnumerable<string> selectedKeys = null, IEnumerable<string> selectedKeys = null,
String redirectClassNameForKey = null) string redirectClassNameForKey = null)
{ {
if (source == null) if (source == null)
{ {
@ -295,13 +295,13 @@ namespace LeanCloud
return newIncludes; return newIncludes;
} }
private HashSet<String> MergeSelectedKeys(IEnumerable<String> selectedKeys) private HashSet<string> MergeSelectedKeys(IEnumerable<string> selectedKeys)
{ {
if (this.selectedKeys == null) if (this.selectedKeys == null)
{ {
return new HashSet<string>(selectedKeys); return new HashSet<string>(selectedKeys);
} }
var newSelectedKeys = new HashSet<String>(this.selectedKeys); var newSelectedKeys = new HashSet<string>(this.selectedKeys);
foreach (var item in selectedKeys) foreach (var item in selectedKeys)
{ {
newSelectedKeys.Add(item); newSelectedKeys.Add(item);

View File

@ -225,7 +225,7 @@ namespace LeanCloud.Storage.Internal {
} }
public static string Encode(string text) { public static string Encode(string text) {
if (String.IsNullOrEmpty(text)) if (string.IsNullOrEmpty(text))
return ""; return "";
byte[] bs = Encoding.UTF8.GetBytes(text); byte[] bs = Encoding.UTF8.GetBytes(text);
string encodedStr = Convert.ToBase64String(bs); string encodedStr = Convert.ToBase64String(bs);

View File

@ -24,8 +24,8 @@ namespace LeanCloud.Storage.Internal
} }
public TypeInfo TypeInfo { get; private set; } public TypeInfo TypeInfo { get; private set; }
public String ClassName { get; private set; } public string ClassName { get; private set; }
public IDictionary<String, String> PropertyMappings { get; private set; } public IDictionary<string, string> PropertyMappings { get; private set; }
private ConstructorInfo Constructor { get; set; } private ConstructorInfo Constructor { get; set; }
public AVObject Instantiate() public AVObject Instantiate()
@ -33,7 +33,7 @@ namespace LeanCloud.Storage.Internal
return (AVObject)Constructor.Invoke(null); return (AVObject)Constructor.Invoke(null);
} }
internal static String GetClassName(TypeInfo type) internal static string GetClassName(TypeInfo type)
{ {
var attribute = type.GetCustomAttribute<AVClassNameAttribute>(); var attribute = type.GetCustomAttribute<AVClassNameAttribute>();
return attribute != null ? attribute.ClassName : null; return attribute != null ? attribute.ClassName : null;

View File

@ -15,7 +15,7 @@ namespace LeanCloud.Storage.Internal {
public ObjectSubclassingController() { public ObjectSubclassingController() {
mutex = new ReaderWriterLockSlim(); mutex = new ReaderWriterLockSlim();
registeredSubclasses = new Dictionary<String, ObjectSubclassInfo>(); registeredSubclasses = new Dictionary<string, ObjectSubclassInfo>();
registerActions = new Dictionary<string, Action>(); registerActions = new Dictionary<string, Action>();
// Register the AVObject subclass, so we get access to the ACL, // Register the AVObject subclass, so we get access to the ACL,
@ -112,7 +112,7 @@ namespace LeanCloud.Storage.Internal {
mutex.ExitWriteLock(); mutex.ExitWriteLock();
} }
public AVObject Instantiate(String className) { public AVObject Instantiate(string className) {
ObjectSubclassInfo info = null; ObjectSubclassInfo info = null;
mutex.EnterReadLock(); mutex.EnterReadLock();
@ -124,8 +124,7 @@ namespace LeanCloud.Storage.Internal {
: new AVObject(className); : new AVObject(className);
} }
public IDictionary<String, String> GetPropertyMappings(String className) { public IDictionary<string, string> GetPropertyMappings(string className) {
ObjectSubclassInfo info = null;
mutex.EnterReadLock(); mutex.EnterReadLock();
registeredSubclasses.TryGetValue(className, out info); registeredSubclasses.TryGetValue(className, out info);
if (info == null) { if (info == null) {

View File

@ -17,7 +17,7 @@ namespace LeanCloud.Storage.Internal {
return query.ClassName; return query.ClassName;
} }
public static IDictionary<String, object> BuildParameters<T>(this AVQuery<T> query) where T: AVObject { public static IDictionary<string, object> BuildParameters<T>(this AVQuery<T> query) where T: AVObject {
return query.BuildParameters(false); return query.BuildParameters(false);
} }

View File

@ -38,7 +38,7 @@ namespace LeanCloud {
/// AVObjects themselves.</param> /// AVObjects themselves.</param>
/// <param name="cancellationToken">The cancellation token.</param> /// <param name="cancellationToken">The cancellation token.</param>
/// <returns>The result of the cloud call.</returns> /// <returns>The result of the cloud call.</returns>
public static Task<T> CallFunctionAsync<T>(String name, IDictionary<string, object> parameters = null, CancellationToken cancellationToken = default) { public static Task<T> CallFunctionAsync<T>(string name, IDictionary<string, object> parameters = null, CancellationToken cancellationToken = default) {
return CloudCodeController.CallFunctionAsync<T>(name, parameters, cancellationToken); return CloudCodeController.CallFunctionAsync<T>(name, parameters, cancellationToken);
} }
@ -50,7 +50,7 @@ namespace LeanCloud {
/// <param name="parameters"></param> /// <param name="parameters"></param>
/// <param name="cancellationToken"></param> /// <param name="cancellationToken"></param>
/// <returns></returns> /// <returns></returns>
public static Task<T> RPCFunctionAsync<T>(String name, IDictionary<string, object> parameters = null, CancellationToken cancellationToken = default) { public static Task<T> RPCFunctionAsync<T>(string name, IDictionary<string, object> parameters = null, CancellationToken cancellationToken = default) {
return CloudCodeController.RPCFunction<T>(name, parameters, cancellationToken); return CloudCodeController.RPCFunction<T>(name, parameters, cancellationToken);
} }
@ -134,10 +134,10 @@ namespace LeanCloud {
{ "mobilePhoneNumber", mobilePhoneNumber }, { "mobilePhoneNumber", mobilePhoneNumber },
}; };
strs.Add("template", template); strs.Add("template", template);
if (String.IsNullOrEmpty(sign)) { if (string.IsNullOrEmpty(sign)) {
strs.Add("sign", sign); strs.Add("sign", sign);
} }
if (String.IsNullOrEmpty(validateToken)) { if (string.IsNullOrEmpty(validateToken)) {
strs.Add("validate_token", validateToken); strs.Add("validate_token", validateToken);
} }
foreach (var key in env.Keys) { foreach (var key in env.Keys) {
@ -233,7 +233,7 @@ namespace LeanCloud {
/// <param name="cancellationToken">CancellationToken.</param> /// <param name="cancellationToken">CancellationToken.</param>
/// <returns>an instance of Captcha.</returns> /// <returns>an instance of Captcha.</returns>
public static Task<Captcha> RequestCaptchaAsync(int width = 85, int height = 30, CancellationToken cancellationToken = default) { public static Task<Captcha> RequestCaptchaAsync(int width = 85, int height = 30, CancellationToken cancellationToken = default) {
var path = String.Format("requestCaptcha?width={0}&height={1}", width, height); var path = string.Format("requestCaptcha?width={0}&height={1}", width, height);
var command = new AVCommand { var command = new AVCommand {
Path = $"requestCaptcha?width={width}&height={height}", Path = $"requestCaptcha?width={width}&height={height}",
Method = HttpMethod.Get Method = HttpMethod.Get

View File

@ -97,11 +97,11 @@ namespace LeanCloud {
CancellationToken cancellationToken = default) where T : AVObject { CancellationToken cancellationToken = default) where T : AVObject {
var queryString = new Dictionary<string, object>(); var queryString = new Dictionary<string, object>();
if (keys != null) { if (keys != null) {
var encode = String.Join(",", keys.ToArray()); var encode = string.Join(",", keys.ToArray());
queryString.Add("keys", encode); queryString.Add("keys", encode);
} }
if (includes != null) { if (includes != null) {
var encode = String.Join(",", includes.ToArray()); var encode = string.Join(",", includes.ToArray());
queryString.Add("include", encode); queryString.Add("include", encode);
} }
if (includeACL != null) { if (includeACL != null) {

View File

@ -353,7 +353,7 @@ namespace LeanCloud {
/// </summary> /// </summary>
public string ObjectId { public string ObjectId {
get { get {
String str; string str;
lock (this.mutex) { lock (this.mutex) {
str = state.ObjectId; str = state.ObjectId;
} }

View File

@ -210,7 +210,6 @@ namespace LeanCloud {
} }
private static string GetFieldForPropertyName(string className, string propertyName) { private static string GetFieldForPropertyName(string className, string propertyName) {
String fieldName = null;
SubclassingController.GetPropertyMappings(className).TryGetValue(propertyName, out fieldName); SubclassingController.GetPropertyMappings(className).TryGetValue(propertyName, out fieldName);
return fieldName; return fieldName;
} }
@ -1631,7 +1630,7 @@ string propertyName
/// </summary> /// </summary>
protected virtual void OnFieldsChanged(IEnumerable<string> fieldNames) { protected virtual void OnFieldsChanged(IEnumerable<string> fieldNames) {
var mappings = SubclassingController.GetPropertyMappings(ClassName); var mappings = SubclassingController.GetPropertyMappings(ClassName);
IEnumerable<String> properties; IEnumerable<string> properties;
if (fieldNames != null && mappings != null) { if (fieldNames != null && mappings != null) {
properties = from m in mappings properties = from m in mappings
@ -1640,7 +1639,7 @@ string propertyName
} else if (mappings != null) { } else if (mappings != null) {
properties = mappings.Keys; properties = mappings.Keys;
} else { } else {
properties = Enumerable.Empty<String>(); properties = Enumerable.Empty<string>();
} }
foreach (var property in properties) { foreach (var property in properties) {

View File

@ -309,7 +309,7 @@ namespace LeanCloud {
Dictionary<string, object> strs = new Dictionary<string, object> { Dictionary<string, object> strs = new Dictionary<string, object> {
{ "mobilePhoneNumber", mobilePhoneNumber }, { "mobilePhoneNumber", mobilePhoneNumber },
}; };
if (String.IsNullOrEmpty(validateToken)) { if (string.IsNullOrEmpty(validateToken)) {
strs.Add("validate_token", validateToken); strs.Add("validate_token", validateToken);
} }
var command = new AVCommand { var command = new AVCommand {
@ -423,7 +423,7 @@ namespace LeanCloud {
Dictionary<string, object> strs = new Dictionary<string, object> { Dictionary<string, object> strs = new Dictionary<string, object> {
{ "mobilePhoneNumber", mobilePhoneNumber }, { "mobilePhoneNumber", mobilePhoneNumber },
}; };
if (String.IsNullOrEmpty(validateToken)) { if (string.IsNullOrEmpty(validateToken)) {
strs.Add("validate_token", validateToken); strs.Add("validate_token", validateToken);
} }
var command = new AVCommand { var command = new AVCommand {