2020-03-18 16:21:29 +08:00
|
|
|
|
using System.Collections.Generic;
|
2020-03-18 11:41:13 +08:00
|
|
|
|
using LeanCloud.Storage;
|
|
|
|
|
|
|
|
|
|
namespace LeanCloud.Realtime {
|
|
|
|
|
public class LCIMImageMessage : LCIMFileMessage {
|
|
|
|
|
public int Width {
|
|
|
|
|
get {
|
|
|
|
|
if (int.TryParse(File.MetaData["width"] as string, out int width)) {
|
|
|
|
|
return width;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public int Height {
|
|
|
|
|
get {
|
|
|
|
|
if (int.TryParse(File.MetaData["height"] as string, out int height)) {
|
|
|
|
|
return height;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-18 16:21:29 +08:00
|
|
|
|
internal LCIMImageMessage() : base() {
|
|
|
|
|
}
|
|
|
|
|
|
2020-03-18 11:41:13 +08:00
|
|
|
|
public LCIMImageMessage(LCFile file) : base(file) {
|
2020-03-18 16:21:29 +08:00
|
|
|
|
|
2020-03-12 16:23:21 +08:00
|
|
|
|
}
|
2020-03-18 16:21:29 +08:00
|
|
|
|
|
|
|
|
|
internal override Dictionary<string, object> Encode() {
|
|
|
|
|
Dictionary<string, object> data = base.Encode();
|
|
|
|
|
Dictionary<string, object> fileData = data["_lcfile"] as Dictionary<string, object>;
|
|
|
|
|
Dictionary<string, object> metaData = fileData["metaData"] as Dictionary<string, object>;
|
2020-03-24 17:42:04 +08:00
|
|
|
|
if (File.MetaData.TryGetValue("width", out object width)) {
|
|
|
|
|
metaData["width"] = width;
|
|
|
|
|
}
|
|
|
|
|
if (File.MetaData.TryGetValue("height", out object height)) {
|
|
|
|
|
metaData["height"] = height;
|
|
|
|
|
}
|
2020-03-18 16:21:29 +08:00
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
internal override int MessageType => ImageMessageType;
|
2020-03-12 16:23:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|