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 {
|
2020-04-27 17:44:14 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 图像消息
|
|
|
|
|
/// </summary>
|
2020-03-18 11:41:13 +08:00
|
|
|
|
public class LCIMImageMessage : LCIMFileMessage {
|
2020-04-27 17:44:14 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 图像宽度
|
|
|
|
|
/// </summary>
|
2020-03-18 11:41:13 +08:00
|
|
|
|
public int Width {
|
2020-04-27 17:44:14 +08:00
|
|
|
|
get; private set;
|
2020-03-18 11:41:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
2020-04-27 17:44:14 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// 图像高度
|
|
|
|
|
/// </summary>
|
2020-03-18 11:41:13 +08:00
|
|
|
|
public int Height {
|
2020-04-27 17:44:14 +08:00
|
|
|
|
get; private set;
|
2020-03-18 11:41:13 +08:00
|
|
|
|
}
|
|
|
|
|
|
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();
|
2020-04-27 17:44:14 +08:00
|
|
|
|
Dictionary<string, object> fileData = data[MessageFileKey] as Dictionary<string, object>;
|
|
|
|
|
Dictionary<string, object> metaData = fileData[MessageDataMetaDataKey] as Dictionary<string, object>;
|
2020-04-28 11:12:25 +08:00
|
|
|
|
if (File.MetaData != null) {
|
|
|
|
|
if (File.MetaData.TryGetValue(MessageDataMetaWidthKey, out object width)) {
|
|
|
|
|
metaData[MessageDataMetaWidthKey] = width;
|
|
|
|
|
}
|
|
|
|
|
if (File.MetaData.TryGetValue(MessageDataMetaHeightKey, out object height)) {
|
|
|
|
|
metaData[MessageDataMetaHeightKey] = height;
|
|
|
|
|
}
|
2020-03-24 17:42:04 +08:00
|
|
|
|
}
|
2020-03-18 16:21:29 +08:00
|
|
|
|
return data;
|
|
|
|
|
}
|
|
|
|
|
|
2020-04-27 17:44:14 +08:00
|
|
|
|
internal override void Decode(Dictionary<string, object> msgData) {
|
|
|
|
|
base.Decode(msgData);
|
2020-04-28 11:12:25 +08:00
|
|
|
|
|
|
|
|
|
if (File.MetaData == null) {
|
|
|
|
|
return;
|
|
|
|
|
}
|
2020-04-27 17:44:14 +08:00
|
|
|
|
if (File.MetaData.TryGetValue(MessageDataMetaWidthKey, out object width) &&
|
|
|
|
|
int.TryParse(width as string, out int w)) {
|
|
|
|
|
Width = w;
|
|
|
|
|
}
|
|
|
|
|
if (File.MetaData.TryGetValue(MessageDataMetaHeightKey, out object height) &&
|
|
|
|
|
int.TryParse(height as string, out int h)) {
|
|
|
|
|
Height = h;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public override int MessageType => ImageMessageType;
|
2020-03-12 16:23:21 +08:00
|
|
|
|
}
|
|
|
|
|
}
|