コード例 #1
0
        public IEvent Load(long index)
        {
            if (index < 0)
            {
                throw new InvalidOperationException("Event index must be >= 0!");
            }
            if (_directory.ContainsKey(index) is false)
            {
                throw new InvalidOperationException($"Event with index {index} was not stored!");
            }

            var text = _directory[index];

            return(EventSerialization.Deserialize(text));
        }
コード例 #2
0
        public IEvent Load(long index)
        {
            if (index < 0)
            {
                throw new InvalidOperationException("Event index must be >= 0!");
            }
            var doc = _directory.FindOne(x => x.Id.Equals(index));

            if (doc is null)
            {
                throw new InvalidOperationException($"Event with index {index} was not stored!");
            }

            return(EventSerialization.Deserialize(doc.Text));
        }
コード例 #3
0
        public void Store(long index, IEvent e)
        {
            var text = EventSerialization.Serialize(e);

            Store(index, text);
        }
コード例 #4
0
        public Event Load(long index)
        {
            var text = File.ReadAllText(FilepathFor(index));

            return(EventSerialization.Deserialize(text));
        }