Esempio n. 1
0
        private IMessage UpdateCollection(UpdateCollectionMessage updateCollectionMessage, IList messages)
        {
            IList updateCollectionRanges = updateCollectionMessage.body as IList;

            for (int i = 0; i < updateCollectionRanges.Count; i++)
            {
                UpdateCollectionRange updateCollectionRange = updateCollectionRanges[i] as UpdateCollectionRange;
                for (int j = 0; j < updateCollectionRange.identities.Length; j++)
                {
                    string   messageId = updateCollectionRange.identities[j] as string;
                    Identity identity  = null;
                    if (messageId != null)
                    {
                        //Search for previous Create or CreateAndSequence
                        //This was a "pending update collection" sent from the client and it must be replaced by the actual Identity
                        IMessage    refMessage  = GetMessage(messages, messageId);
                        DataMessage dataMessage = refMessage as DataMessage;
                        if (dataMessage != null)
                        {
                            DataDestination dataDestination = this.Destination as DataDestination;
                            identity = Identity.GetIdentity(dataMessage.body, dataDestination);
                        }
                        //replace with the actual identity
                        updateCollectionRange.identities[j] = identity;
                    }
                    else
                    {
                        IDictionary identityMap = updateCollectionRange.identities[j] as IDictionary;
                        if (identityMap != null)
                        {
                            identity = new Identity(identityMap);
                        }
                    }

                    IList fillParameters = updateCollectionMessage.collectionId as IList;

                    IAssembler assembler = GetAssembler();
                    if (assembler != null)
                    {
                        if (updateCollectionRange.updateType == UpdateCollectionRange.InsertIntoCollection)
                        {
                            assembler.AddItemToFill(fillParameters, updateCollectionRange.position + j, identity);
                        }
                        if (updateCollectionRange.updateType == UpdateCollectionRange.DeleteFromCollection)
                        {
                            assembler.RemoveItemFromFill(fillParameters, updateCollectionRange.position, identity);
                        }
                    }
                }
            }
            return(updateCollectionMessage);
        }
Esempio n. 2
0
        private IMessage UpdateCollection(UpdateCollectionMessage updateCollectionMessage, IList messages)
        {
            IList body = updateCollectionMessage.body as IList;

            for (int i = 0; i < body.Count; i++)
            {
                UpdateCollectionRange range = body[i] as UpdateCollectionRange;
                for (int j = 0; j < range.identities.Length; j++)
                {
                    string   messageId = range.identities[j] as string;
                    Identity identity  = null;
                    if (messageId != null)
                    {
                        DataMessage message = this.GetMessage(messages, messageId) as DataMessage;
                        if (message != null)
                        {
                            DataDestination destination = base.Destination as DataDestination;
                            identity = Identity.GetIdentity(message.body, destination);
                        }
                        range.identities[j] = identity;
                    }
                    else
                    {
                        IDictionary map = range.identities[j] as IDictionary;
                        if (map != null)
                        {
                            identity = new Identity(map);
                        }
                    }
                    IList      collectionId = updateCollectionMessage.collectionId;
                    IAssembler assembler    = this.GetAssembler();
                    if (assembler != null)
                    {
                        if (range.updateType == 0)
                        {
                            assembler.AddItemToFill(collectionId, range.position + j, identity);
                        }
                        if (range.updateType == 1)
                        {
                            assembler.RemoveItemFromFill(collectionId, range.position, identity);
                        }
                    }
                }
            }
            return(updateCollectionMessage);
        }
		/// <summary>
		/// This method supports the infrastructure and is not intended to be used directly from your code.
		/// </summary>
		/// <param name="updateType"></param>
		/// <param name="position"></param>
		/// <param name="identity"></param>
		public void AddItemIdentityChange(int updateType, int position, object identity) {
			UpdateCollectionRange range = new UpdateCollectionRange();
			range.position = position;
			range.updateType = updateType;
			range.identities = new object[1];
			range.identities[0] = identity;

			object[] bodyArray = this.body as object[];
			if (bodyArray == null) {
				bodyArray = new object[1];
				bodyArray[0] = range;
			} else {
				object[] newbody = new object[bodyArray.Length + 1];
				bodyArray.CopyTo(newbody, 0);
				bodyArray[bodyArray.Length - 1] = range;
			}
			this.body = bodyArray;
		}
Esempio n. 4
0
        public void AddItemIdentityChange(int updateType, int position, object identity)
        {
            UpdateCollectionRange range = new UpdateCollectionRange {
                position   = position,
                updateType = updateType,
                identities = new object[] { identity }
            };

            object[] body = base.body as object[];
            if (body == null)
            {
                body = new object[] { range };
            }
            else
            {
                object[] array = new object[body.Length + 1];
                body.CopyTo(array, 0);
                body[body.Length - 1] = range;
            }
            base.body = body;
        }
Esempio n. 5
0
        /// <summary>
        /// This method supports the Fluorine infrastructure and is not intended to be used directly from your code.
        /// </summary>
        /// <param name="updateType"></param>
        /// <param name="position"></param>
        /// <param name="identity"></param>
        public void AddItemIdentityChange(int updateType, int position, object identity)
        {
            UpdateCollectionRange range = new UpdateCollectionRange();

            range.position      = position;
            range.updateType    = updateType;
            range.identities    = new object[1];
            range.identities[0] = identity;

            object[] bodyArray = this.body as object[];
            if (bodyArray == null)
            {
                bodyArray    = new object[1];
                bodyArray[0] = range;
            }
            else
            {
                object[] newbody = new object[bodyArray.Length + 1];
                bodyArray.CopyTo(newbody, 0);
                bodyArray[bodyArray.Length - 1] = range;
            }
            this.body = bodyArray;
        }