Skip to content

Instantly share code, notes, and snippets.

@aconfee
Last active July 17, 2018 18:13
Show Gist options
  • Save aconfee/99d2b8435e4f7060fa40df230e84ecb8 to your computer and use it in GitHub Desktop.
Save aconfee/99d2b8435e4f7060fa40df230e84ecb8 to your computer and use it in GitHub Desktop.
MessageAdapter
public class MessageOperationPacket<TMessage>
{
public MessageOperationPacket(QueueItem queueItem)
{
this.queueItem = queueItem;
}
protected QueueItem queueItem { get; }
protected TMessage data
{
get
{
if (this._message == null)
{
this._message = JsonConvert.DeserializeObject<TMessage>(this.QueueItem.WorkData);
}
return this._message;
}
}
private TMessage _message;
}
public class MyFancyMessageOperation : MessageOperationPacket<MyFancyMessageOperation>
{
public MyFancyMessageOperation(QueueItem queueItem)
: base(queueItem) {}
public Guid? AdditionalDataId => this.queueItem.AdditionalDataId;
public string Thing
{
get => this.data.Thing;
set => this.data.Thing = value;
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment