public bool Equals(NarrationInformation other) { if (other == null) { return(false); } return(ViewIndex.Equals(other.ViewIndex) && MessageIndex.Equals(other.MessageIndex) && SubIndex.Equals(other.SubIndex)); }
public void Consume(MessageCreated message) { Trace.TraceInformation("DENORMALIZING MESSAGE CREATED EVENT {0}[{1}]...", message.Message, message.Id); MyMessageContext context = contextFactory(); var entity = new MessageView { Context = context, Message = message.Message, UtcCreated = message.UtcCreated }; storage.AddOrUpdateEntity(message.Id, entity); storage.AddOrUpdateSingleton(() => { var index = new MessageIndex(); index.Messages.Add(message.Id, message.Message); return(index); }, i => i.Messages[message.Id] = message.Message); }
private async void LoadMore(bool force = false) { LoadingVisibility = true; if (force) { if (DisplaySentMessages) { Outbox = new List <MalMessageModel>(); } else { _loadedPages = 1; Inbox = new List <MalMessageModel>(); } } if (!DisplaySentMessages) { try { if (!_skipLoading) { _loadedSomething = true; try { Inbox.AddRange(await AccountMessagesManager.GetMessagesAsync(_loadedPages++)); } catch (WebException) { ResourceLocator.MalHttpContextProvider.ErrorMessage("Messages"); } } _skipLoading = false; MessageIndex.Clear(); MessageIndex.AddRange(Inbox); LoadMorePagesVisibility = true; } catch (ArgumentOutOfRangeException) { LoadMorePagesVisibility = false; } } else { try { if (Outbox.Count == 0) { Outbox = await AccountMessagesManager.GetSentMessagesAsync(); } MessageIndex.Clear(); MessageIndex.AddRange(Outbox); LoadMorePagesVisibility = false; } catch (Exception) { ResourceLocator.MalHttpContextProvider.ErrorMessage("Messages"); } } LoadingVisibility = false; }
/// <summary>Get the hashcode of the Value.</summary> public override int GetHashCode() { return(ViewIndex.GetHashCode() ^ MessageIndex.GetHashCode() ^ SubIndex.GetHashCode()); }
private IMessage MessageRead(int iMsgIndexFind) { if (iMsgIndexFind < 0 || iMsgIndexFind >= _alMessages.Count) { return(null); } MessageIndex messageIndex = (MessageIndex)_alMessages[iMsgIndexFind]; byte[] tBuffer; int iStep; int iMsgIndex, iMsgIndexEnd; long lOffset = 0; lock (_lockRead) { if (iMsgIndexFind > _iMsgIndexReader) { iStep = 1; iMsgIndex = _iMsgIndexReader; iMsgIndexEnd = iMsgIndexFind; } else { iStep = -1; iMsgIndex = iMsgIndexFind; iMsgIndexEnd = _iMsgIndexReader; } while (iMsgIndex != iMsgIndexEnd) { lOffset += ((MessageIndex)_alMessages[iMsgIndex]).Length; iMsgIndex += 1; } lOffset *= iStep; if (log.IsDebugEnabled) { log.DebugFormat("MessageRead - Before Seek / Position={0} Offset={1}", _sLog.Position, lOffset); } _sLog.Seek(lOffset, SeekOrigin.Current); if (log.IsDebugEnabled) { log.DebugFormat("MessageRead - After Seek / Position={0}", _sLog.Position); } tBuffer = new byte[messageIndex.Length]; _sLog.Read(tBuffer, 0, messageIndex.Length); _iMsgIndexReader = iMsgIndexFind + 1; } string sMessage = _encoding.GetString(tBuffer, 2, tBuffer.Length - 4); if (log.IsDebugEnabled) { log.DebugFormat("MessageRead - Read message from disk / Message={0}", sMessage); } IMessage message = _messageFactory.Parse(sMessage); message.Direction = messageIndex.Direction; return(message); }