public void UpdateManifest(IUniqueIdentity id, int currentVersion, int newVersion)
        {
            Console.WriteLine(string.Format("Update manifest {0} - {1} - {2}", id, currentVersion, newVersion));

            var updated = SynchronousTask.GetSync(() => this.DoUpdate(id, currentVersion, newVersion));

            if (!updated)
            {
                Console.WriteLine("AggregateManifest FAILED");
                throw new ConcurrencyException();
            }
        }
        private bool DoUpdate(IUniqueIdentity id, int currentVersion, int newVersion)
        {
            if (currentVersion == 0)
            {
                this.connection.Insert(new AggregateManifest { Id = id.Id, Version = newVersion, AggregateType = id.GetType().Name });
            }
            else
            {
                var rows = this.connection.Execute(UpdateSql, newVersion, id.Id, currentVersion);
                return rows == 1;
            }

            return true;
        }
        public ScheduledDeedsController(MinionContext context, IUniqueIdentity minionId)
            : base(UITableViewStyle.Grouped)
        {
            this.lifetime = new CompositeDisposable();

            this.NavigationItem.Title = "Scheduled Deeds";
            this.NavigationItem.RightBarButtonItem = new UIBarButtonItem(UIBarButtonSystemItem.Add);
            this.NavigationItem.RightBarButtonItem.Clicked += AddClicked;

            this.context = context;
            this.minionId = minionId;
        }
Exemple #4
0
 public IdLock(IUniqueIdentity id)
 {
     this.id = id;
     this.lockObject = Locks.GetOrAdd(id, x => new object());
     Monitor.Enter(this.lockObject);
 }
Exemple #5
0
 public DataModelChange(IUniqueIdentity id, bool deleted)
 {
     this.Identity = id;
     this.Deleted = deleted;
 }
Exemple #6
0
 public DataModelChange(IUniqueIdentity id)
 {
     this.Identity = id;
     this.Deleted = true;
 }
Exemple #7
0
        protected void RaiseEvent(IUniqueIdentity id, IAggregateEvent evt)
        {
            if (id == null || id.Id == Guid.Empty)
            {
                throw new ArgumentNullException("id", "Cannot raise an event without specifying the correct aggregate id");
            }

            if (this.Identity == null)
            {
                this.Identity = id;
            }

            if (this.Identity.Id != id.Id)
            {
                throw new InvalidOperationException("Cannot raise an event for a different aggregate root id");
            }

            this.Version++;

            evt.Identity = id;
            evt.EventId = Guid.NewGuid();
            evt.Version = this.Version;
            evt.Timestamp = DateTime.UtcNow;

            this.ApplyEvent(evt);
            this.uncommittedEvents.Add(evt);
        }