示例#1
0
        private void SendObjectInsertedPayload(ObjectInsertedPayload data)
        {
            // Add to pending list
            CollectionOperation change = new CollectionOperation(data);

            this.LocalOperations.Add(change);

            this.client.SendPublishEvent(data);
        }
示例#2
0
        override internal void OnObjectInserted(ObjectInsertedPayload data)
        {
            if (data.ClientId == this.client.ClientId)
            {
                Debug.Assert(UnackedMessages > 0);
                --UnackedMessages;
                return;
            }

            BaseOnObjectInserted(data);
        }
示例#3
0
        private void OnObjectInserted(ObjectInsertedPayload data)
        {
            CollectionEntry collectionEntry;

            if (!this.client.CollectionsManager.TryGetValue(data.Parent.Id, out collectionEntry))
            {
                Debug.WriteLine("Missing collection for incoming object insertion");
                return;
            }

            // Route insert request to the collection entry
            collectionEntry.OnObjectInserted(data);
        }
示例#4
0
        private void AddSharedObjects(IList items)
        {
            Debug.Assert(client.CheckAccess());

            foreach (INotifyPropertyChanged addedObj in items)
            {
                ObjectEntry objectEntry;
                if (AddSharedObject(addedObj, -1, out objectEntry))
                {
                    Debug.WriteLine(string.Format("[UnorderedCollection] - Client={0}: LOCAL Inserting {1}", this.client.ClientId, objectEntry.Object));

                    var payload = new ObjectInsertedPayload(this.Id, objectEntry.Id, this.client.ClientId);
                    SendObjectInsertedPayload(payload);
                }
            }
        }
示例#5
0
        private void AddSharedObjects(IList items)
        {
            Debug.Assert(client.CheckAccess());

            foreach (INotifyPropertyChanged addedObj in items)
            {
                int         index = this.GetMasterCollection().IndexOf(addedObj);
                ObjectEntry objectEntry;
                if (AddSharedObject(addedObj, index, out objectEntry))
                {
                    this.CollectionIndices.Insert(index, objectEntry.Id);

                    Debug.WriteLine(string.Format("[OrderedCollection] - Client={0}: LOCAL Inserting {1} in position {2}", this.client.ClientId, objectEntry.Object, index));

                    var payload = new ObjectInsertedPayload(this.Id, objectEntry.Id, index, this.OperationSequence, this.client.ClientId);
                    SendObjectInsertedPayload(payload);
                }
            }
        }
示例#6
0
        override internal void OnObjectInserted(ObjectInsertedPayload data)
        {
            Debug.Assert(this.IsConnected == false || this.OperationSequence == 0 || data.OperationSequence == this.OperationSequence + 1);
            this.OperationSequence = data.OperationSequence;

            // Check if this is a locally pending insert, if so remove the insert from the list of LocalOperations
            if (data.ClientId == this.client.ClientId)
            {
                this.ProcessAck(OperationAction.Insert, data.ObjectId);
                return;
            }

            // Apply transformation, update index
            CollectionOperation operation = new CollectionOperation(data);

            this.ApplyTransform(this, ref operation);
            data.Parent.Index = operation.ObjectIndex;

            if (operation.ApplyOperation)
            {
                BaseOnObjectInserted(data);
            }
        }
示例#7
0
        protected void BaseOnObjectInserted(ObjectInsertedPayload data)
        {
            ObjectEntry objectEntry;

            if (!this.client.ObjectsManager.TryGetValue(data.ObjectId, out objectEntry))
            {
                Debug.Assert(false, "Missing object for incoming object insertion");
                return;
            }

            Debug.Assert(client.CheckAccess());
            Debug.Assert(!this.Items.ContainsKey(data.ObjectId), "Cannot re-insert object with same ID as existing object");

            objectEntry.AddParent(data.Parent);

            try
            {
                objectEntry.IgnoreChanges = true;

                if (this.Items.ContainsKey(objectEntry.Id))
                {
                    // TODO: this can happen due to a race condition
                    Debug.Assert(false, "Trying to add object to collection it already contains");
                }
                else
                {
                    this.Items.Add(objectEntry.Id, objectEntry);
                    AddObjectToCollection(data, objectEntry);
                    Debug.WriteLine(string.Format("[OrderedCollection] - Client={0}: REMOTE Inserting {1} in position {2}", this.client.ClientId, objectEntry.Object, data.Parent.Index));
                }
            }
            finally
            {
                objectEntry.IgnoreChanges = false;
            }
        }
示例#8
0
 public CollectionOperation(ObjectInsertedPayload data)
     : this(data as CollectionChangedPayload)
 {
     this.Action = OperationAction.Insert;
 }
示例#9
0
 protected override void AddObjectToCollection(ObjectInsertedPayload data, ObjectEntry objectEntry)
 {
     this.GetMasterCollection().IncomingInsert(data.Parent.Index, objectEntry.Object);
     this.CollectionIndices.Insert(data.Parent.Index, objectEntry.Id);
 }
示例#10
0
 private void SendObjectInsertedPayload(ObjectInsertedPayload data)
 {
     this.client.SendPublishEvent(data);
     ++UnackedMessages;
 }
示例#11
0
 protected override void AddObjectToCollection(ObjectInsertedPayload data, ObjectEntry objectEntry)
 {
     this.GetMasterCollection().IncomingAdd(objectEntry.Object);
 }
示例#12
0
 abstract protected void AddObjectToCollection(ObjectInsertedPayload data, ObjectEntry objectEntry);
示例#13
0
 abstract internal void OnObjectInserted(ObjectInsertedPayload data);