public StreamDocument(LogicLong id, LogicLong ownerId, AvatarStreamEntry entry) : base(id) { this.CreateTime = DateTime.UtcNow; this.OwnerId = ownerId; this.Type = StreamType.AVATAR; this.Entry = entry; entry.SetId(id); }
protected sealed override void Load(LogicJSONObject jsonObject) { LogicJSONArray ownerIdArray = jsonObject.GetJSONArray(StreamDocument.JSON_ATTRIBUTE_OWNER_ID); this.OwnerId = new LogicLong(ownerIdArray.GetJSONNumber(0).GetIntValue(), ownerIdArray.GetJSONNumber(1).GetIntValue()); this.CreateTime = DateTime.Parse(jsonObject.GetJSONString(StreamDocument.JSON_ATTRIBUTE_CREATE_TIME).GetStringValue()); this.Type = (StreamType)jsonObject.GetJSONNumber(StreamDocument.JSON_ATTRIBUTE_TYPE).GetIntValue(); switch (this.Type) { case StreamType.ALLIANCE: { StreamEntry entry = StreamEntryFactory.CreateStreamEntryByType((StreamEntryType)jsonObject.GetJSONNumber(StreamDocument.JSON_ATTRIBUTE_ENTRY_TYPE).GetIntValue()); entry.Load(jsonObject.GetJSONObject(StreamDocument.JSON_ATTRIBUTE_ENTRY)); entry.SetId(this.Id); this.Entry = entry; break; } case StreamType.AVATAR: { AvatarStreamEntry entry = AvatarStreamEntryFactory.CreateStreamEntryByType((AvatarStreamEntryType)jsonObject.GetJSONNumber(StreamDocument.JSON_ATTRIBUTE_ENTRY_TYPE).GetIntValue()); entry.Load(jsonObject.GetJSONObject(StreamDocument.JSON_ATTRIBUTE_ENTRY)); entry.SetId(this.Id); this.Entry = entry; break; } case StreamType.REPLAY: { ReplayStreamEntry entry = new ReplayStreamEntry(); entry.Load(jsonObject.GetJSONObject(StreamDocument.JSON_ATTRIBUTE_ENTRY)); this.Entry = entry; break; } } }