public StreamDocument(LogicLong id, ReplayStreamEntry entry) : base(id)
 {
     this.CreateTime = DateTime.UtcNow;
     this.OwnerId    = new LogicLong();
     this.Type       = StreamType.REPLAY;
     this.Entry      = entry;
 }
        protected sealed override void Save(LogicJSONObject jsonObject)
        {
            LogicJSONArray ownerIdArray = new LogicJSONArray(2);

            ownerIdArray.Add(new LogicJSONNumber(this.OwnerId.GetHigherInt()));
            ownerIdArray.Add(new LogicJSONNumber(this.OwnerId.GetLowerInt()));

            jsonObject.Put(StreamDocument.JSON_ATTRIBUTE_OWNER_ID, ownerIdArray);
            jsonObject.Put(StreamDocument.JSON_ATTRIBUTE_CREATE_TIME, new LogicJSONString(this.CreateTime.ToString("O")));
            jsonObject.Put(StreamDocument.JSON_ATTRIBUTE_TYPE, new LogicJSONNumber((int)this.Type));

            switch (this.Type)
            {
            case StreamType.ALLIANCE:
            {
                LogicJSONObject entryObject = new LogicJSONObject();
                StreamEntry     entry       = (StreamEntry)this.Entry;

                jsonObject.Put(StreamDocument.JSON_ATTRIBUTE_ENTRY_TYPE, new LogicJSONNumber((int)entry.GetStreamEntryType()));
                jsonObject.Put(StreamDocument.JSON_ATTRIBUTE_ENTRY, entryObject);

                entry.Save(entryObject);
                break;
            }

            case StreamType.AVATAR:
            {
                LogicJSONObject   entryObject = new LogicJSONObject();
                AvatarStreamEntry entry       = (AvatarStreamEntry)this.Entry;

                jsonObject.Put(StreamDocument.JSON_ATTRIBUTE_ENTRY_TYPE, new LogicJSONNumber((int)entry.GetAvatarStreamEntryType()));
                jsonObject.Put(StreamDocument.JSON_ATTRIBUTE_ENTRY, entryObject);

                entry.Save(entryObject);
                break;
            }

            case StreamType.REPLAY:
            {
                LogicJSONObject   entryObject = new LogicJSONObject();
                ReplayStreamEntry entry       = (ReplayStreamEntry)this.Entry;

                jsonObject.Put(StreamDocument.JSON_ATTRIBUTE_ENTRY, entryObject);

                entry.Save(entryObject);

                break;
            }
            }
        }
        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;
            }
            }
        }