/// <summary>
        /// Append an event onto the event stream
        /// </summary>
        /// <param name="eventToAppend">
        /// The event we want to write to the event stream
        /// </param>
        /// <param name="expectedTopSequence">
        /// The sequence number we expect to be the last in the event stream - if events have been added since this then a
        /// concurrency error is thrown
        /// </param>
        public async Task AppendEvent(object eventToAppend,
                                      int?expectedTopSequence = null,
                                      EventStreamExistenceConstraint streamConstraint = EventStreamExistenceConstraint.Loose)
        {
            if (null != _writer)
            {
                // make an event instance of this event and append it to the event stream
                IAppendResult result = await _writer.AppendEvent(EventInstance.Wrap(eventToAppend),
                                                                 expectedTopSequence.GetValueOrDefault(0),
                                                                 streamConstraint : streamConstraint);

                if (null != result)
                {
                    if (null != this._notificationDispatcher)
                    {
                        if (result.NewEventStreamCreated)
                        {
                            await _notificationDispatcher.NewEntityCreated(this,
                                                                           commentary : _context?.Commentary,
                                                                           context : _context);
                        }
                        await _notificationDispatcher.NewEventAppended(this,
                                                                       EventNameAttribute.GetEventName(eventToAppend.GetType()),
                                                                       result.SequenceNumber,
                                                                       commentary : _context?.Commentary,
                                                                       eventPayload : eventToAppend,
                                                                       context : _context);
                    }
                }
            }
        }