public virtual void GetObjectData(SerializationInfo info, StreamingContext context) { ParamCheckUtility.ThrowIfNull(info, "info"); info.AddValue(BrokerQueueItem.MessageVersionTag, SerializeMessageVersion(this.Message.Version)); MemoryStream msgStream = null; try { msgStream = new MemoryStream(); using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateBinaryWriter(msgStream)) { var msgStreamTemp = msgStream; msgStream = null; this.Message.WriteMessage(writer); writer.Flush(); info.AddValue(BrokerQueueItem.MessageTag, msgStreamTemp.ToArray()); } } finally { if (msgStream != null) { msgStream.Dispose(); } } BrokerQueueItem.SerializeObject(info, this.asyncState, BrokerQueueItem.AsyncStateTag); BrokerQueueItem.SerializeObject(info, this.persistGuid, BrokerQueueItem.PersistIdTag); }
public object Clone() { var info = new SerializationInfo(typeof(BrokerQueueItem), new FormatterConverter()); var context = new StreamingContext(); info.AddValue(BrokerQueueItem.MessageVersionTag, SerializeMessageVersion(this.Message.Version)); MemoryStream msgStream = null; try { msgStream = new MemoryStream(); using (XmlDictionaryWriter writer = XmlDictionaryWriter.CreateBinaryWriter(msgStream)) { var msgStreamTemp = msgStream; msgStream = null; var msg = this.MessageBuffer.CreateMessage(); msg.WriteMessage(writer); writer.Flush(); info.AddValue(BrokerQueueItem.MessageTag, msgStreamTemp.ToArray()); } } finally { if (msgStream != null) { msgStream.Dispose(); } } BrokerQueueItem.SerializeObject(info, this.asyncState, BrokerQueueItem.AsyncStateTag); BrokerQueueItem.SerializeObject(info, this.persistGuid, BrokerQueueItem.PersistIdTag); var item = new BrokerQueueItem(info, context); // Give it a new id. var newId = new UniqueId(); item.Message.Headers.RemoveAll(Constant.MessageIdHeaderName, Constant.HpcHeaderNS); item.Message.Headers.Add(MessageHeader.CreateHeader(Constant.MessageIdHeaderName, Constant.HpcHeaderNS, newId)); item.Message.Headers.MessageId = newId; item.CleanMessageBuffer(); item.buffer = item.Message.CreateBufferedCopy(BrokerEntry.MaxMessageSize); item.asyncToken.AsyncToken = this.asyncToken.AsyncToken; item.asyncToken.Queue = this.asyncToken.Queue; item.TryCount = this.TryCount; item.DispatchNumber = this.DispatchNumber; item.ReemitToken = this.ReemitToken; return(item); }