void ApplyUpdateCollectionMessage(Sequence sequence, UpdateCollectionMessage updateCollectionMessage) { IList updateCollectionRanges = updateCollectionMessage.body as IList; for (int k = 0; k < updateCollectionRanges.Count; k++) { UpdateCollectionRange updateCollectionRange = updateCollectionRanges[k] as UpdateCollectionRange; int insertCount = 0; for (int l = 0; l < updateCollectionRange.identities.Length; l++) { Identity identity = updateCollectionRange.identities[l] as Identity; if (identity == null) { identity = new Identity(updateCollectionRange.identities[l] as IDictionary); } if (updateCollectionRange.updateType == UpdateCollectionRange.InsertIntoCollection) { this.AddIdentityToSequence(sequence, updateCollectionRange.position + insertCount, identity, null); insertCount++; } if (updateCollectionRange.updateType == UpdateCollectionRange.DeleteFromCollection) { this.RemoveIdentityFromSequence(sequence, identity, updateCollectionRange.position, null); } } } }
private UpdateCollectionMessage CreateUpdateCollectionMessage(DataMessage dataMessage, Sequence sequence, Identity identity, int position, int updateMode) { UpdateCollectionMessage updateCollectionMessage = new UpdateCollectionMessage(); // The unique identifier for the collection that was updated. For a collection filled with the // DataService.fill() method this contains an Array of the parameters specified. updateCollectionMessage.collectionId = sequence.Parameters; updateCollectionMessage.destination = dataMessage.destination; updateCollectionMessage.replace = false; updateCollectionMessage.updateMode = updateMode; updateCollectionMessage.messageId = "srv:" + Guid.NewGuid().ToString("D") + ":0"; updateCollectionMessage.correlationId = dataMessage.correlationId; UpdateCollectionRange updateCollectionRange = new UpdateCollectionRange(); // An Array of identity objects that represent which items were either deleted or inserted in the // associated collection starting at the position indicated by the position property updateCollectionRange.identities = new object[1]; //(updateCollectionRange.identities as IList).Add( identity ); (updateCollectionRange.identities as object[])[0] = identity; updateCollectionRange.updateType = UpdateCollectionRange.InsertIntoCollection; updateCollectionRange.position = position; //ArrayList body = new ArrayList(); //body.Add(updateCollectionRange); object[] body = new object[1]; body[0] = updateCollectionRange; updateCollectionMessage.body = body; return(updateCollectionMessage); }
private UpdateCollectionMessage CreateUpdateCollectionMessage(DataMessage dataMessage, Sequence sequence, Identity identity, int position, int updateMode) { UpdateCollectionMessage updateCollectionMessage = new UpdateCollectionMessage(); // The unique identifier for the collection that was updated. For a collection filled with the // DataService.fill() method this contains an Array of the parameters specified. updateCollectionMessage.collectionId = sequence.Parameters; updateCollectionMessage.destination = dataMessage.destination; updateCollectionMessage.replace = false; updateCollectionMessage.updateMode = updateMode; updateCollectionMessage.messageId = "srv:" + Guid.NewGuid().ToString("D") + ":0"; updateCollectionMessage.correlationId = dataMessage.correlationId; UpdateCollectionRange updateCollectionRange = new UpdateCollectionRange(); // An Array of identity objects that represent which items were either deleted or inserted in the // associated collection starting at the position indicated by the position property updateCollectionRange.identities = new object[1]; //(updateCollectionRange.identities as IList).Add( identity ); (updateCollectionRange.identities as object[])[0] = identity; updateCollectionRange.updateType = UpdateCollectionRange.InsertIntoCollection; updateCollectionRange.position = position; //ArrayList body = new ArrayList(); //body.Add(updateCollectionRange); object[] body = new object[1]; body[0] = updateCollectionRange; updateCollectionMessage.body = body; return updateCollectionMessage; }