Esempio n. 1
0
        public async Task <FileHeader> Execute(IAsyncFilesSession session)
        {
            var commands = session.Commands;

            bool delete = true;

            FileHeader fileHeader = null;

            if (!sessionOperations.TryGetFromCache(FileName, out fileHeader))
            {
                fileHeader = await session.LoadFileAsync(FileName).ConfigureAwait(false);
            }

            foreach (var deleteListener in sessionOperations.Listeners.DeleteListeners)
            {
                if (!deleteListener.BeforeDelete(fileHeader))
                {
                    delete = false;
                }
            }

            if (delete)
            {
                await commands.DeleteAsync(FileName, Etag)
                .ConfigureAwait(false);

                sessionOperations.RegisterMissing(FileName);

                foreach (var deleteListener in sessionOperations.Listeners.DeleteListeners)
                {
                    deleteListener.AfterDelete(FileName);
                }
            }

            return(null);
        }