예제 #1
0
        private string Serialize(IUndoCommand undoCommand)
        {
            var stream     = new MemoryStream();
            var serializer = new XmlSerializer(undoCommand.GetType());

            serializer.Serialize(stream, undoCommand);
            return(Convert.ToBase64String(stream.ToArray()));
        }
예제 #2
0
        public Guid RegisterUndoCommand(string userId, IUndoCommand undoCommand)
        {
            var serializedData = Serialize(undoCommand);
            var uniqueKey      = Guid.NewGuid();

            var undo = new Undo
            {
                UserId         = userId,
                UniqueKey      = uniqueKey,
                TypeKey        = _typeRegistry.GetTypeKeyFromSerializationAttribute(undoCommand.GetType()),
                SerializedData = serializedData,
                CreateDate     = DateTime.UtcNow
            };

            _undoRepository.Insert(undo);
            _unitOfWork.Save();

            return(uniqueKey);
        }