Exemplo n.º 1
0
        protected PutCommandDataBase(string id, string changeVector, T document, ForceRevisionStrategy strategy = ForceRevisionStrategy.None)
        {
            if (document == null)
            {
                throw new ArgumentNullException(nameof(document));
            }

            Id           = id;
            ChangeVector = changeVector;
            Document     = document;
            ForceRevisionCreationStrategy = strategy;
        }
Exemplo n.º 2
0
        public void ForceRevisionCreationFor <T>(T entity, ForceRevisionStrategy strategy = ForceRevisionStrategy.Before)
        {
            if (ReferenceEquals(entity, null))
            {
                throw new ArgumentNullException(nameof(entity));
            }

            if (DocumentsByEntity.TryGetValue(entity, out DocumentInfo documentInfo) == false)
            {
                throw new InvalidOperationException("Cannot create a revision for the requested entity because it is Not tracked by the session");
            }

            AddIdToList(documentInfo.Id, strategy);
        }
Exemplo n.º 3
0
        private void AddIdToList(string id, ForceRevisionStrategy requestedStrategy)
        {
            if (String.IsNullOrEmpty(id))
            {
                throw new InvalidOperationException("Id cannot be null or empty.");
            }

            var idAlreadyAdded = Session.IdsForCreatingForcedRevisions.TryGetValue(id, out var existingStrategy);

            if (idAlreadyAdded && (existingStrategy != requestedStrategy))
            {
                throw new InvalidOperationException($"A request for creating a revision was already made for document {id} in the current session but with a different force strategy." +
                                                    $"New strategy requested: {requestedStrategy}. Previous strategy: {existingStrategy}.");
            }

            if (idAlreadyAdded == false)
            {
                Session.IdsForCreatingForcedRevisions.Add(id, requestedStrategy);
            }
        }
Exemplo n.º 4
0
 public void ForceRevisionCreationFor(string id, ForceRevisionStrategy strategy = ForceRevisionStrategy.Before)
 {
     AddIdToList(id, strategy);
 }
Exemplo n.º 5
0
 public PutCommandData(string id, string changeVector, string originalChangeVector, DynamicJsonValue document, ForceRevisionStrategy strategy)
     : base(id, changeVector, originalChangeVector, document, strategy)
 {
 }
Exemplo n.º 6
0
 public PutCommandData(string id, string changeVector, DynamicJsonValue document, ForceRevisionStrategy strategy)
     : this(id, changeVector, changeVector, document, strategy)
 {
 }
Exemplo n.º 7
0
 public PutCommandDataWithBlittableJson(string id, string changeVector, string originalChangeVector, BlittableJsonReaderObject document, ForceRevisionStrategy strategy)
     : base(id, changeVector, originalChangeVector, document, strategy)
 {
 }