NServiceBus消息和封装
我希望这不是一个白痴问题……我的大脑充满了新的东西,这让我很受伤。
我试图更好地了解 NServiceBus 。
我的消息类如下所示:
public class Address // value object
{
public readonly string AddressLine1;
public readonly string AddressLine2;
public readonly string AddressLine3;
public readonly string City;
public readonly string Country;
public readonly string PostCode;
public Address(string addressLine1,
string addressLine2,
string addressLine3,
string city,
string country,
string postCode)
{
AddressLine1 = addressLine1;
AddressLine2 = addressLine2;
AddressLine3 = addressLine3;
City = city;
Country = country;
PostCode = postCode;
}
}
问题是 NServiceBus 序列化程序无法处理它(可以理解),我最终不得不恢复为自动属性。我可以接受这个学习练习......但是有没有办法使用上面的消息类?
我想我应该问而不是深入研究 NServiceBus 源代码。谢谢!
I hope this is not an idiot question... my brain is so full of new stuff it hurts.
I'm attempting to get to know NServiceBus a little better.
My message classes look like this:
public class Address // value object
{
public readonly string AddressLine1;
public readonly string AddressLine2;
public readonly string AddressLine3;
public readonly string City;
public readonly string Country;
public readonly string PostCode;
public Address(string addressLine1,
string addressLine2,
string addressLine3,
string city,
string country,
string postCode)
{
AddressLine1 = addressLine1;
AddressLine2 = addressLine2;
AddressLine3 = addressLine3;
City = city;
Country = country;
PostCode = postCode;
}
}
Problem is NServiceBus serializer cannot deal with it (understandably so) and i end up having to revert to auto properties. I can live with it for this learning exercise... but is there a way to use the message class above?
I thought I would ask instead of delving into NServiceBus source code. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我已经有一段时间没有使用 NSB 了,但我记得有一个 contrib 模块,其中包含JsonSerializer 基于 Newtonsoft Json.NET 库。
json.net lib 支持对象的(反)序列化,如您所描述的对象。您可以在此处找到有关序列化库支持的更多详细信息。
I have not used NSB for some time, but i remember that there was a contrib module that contains a JsonSerializer based on Newtonsoft Json.NET library.
The json.net lib supports (de)serialization of objects like the one you describe. You can find more details about what is supported by serialization libraries here.
我很确定如果您公开 get/private 设置属性而不是字段,它会起作用。
I'm pretty sure it'll work if you expose get/private set properties rather than fields.