Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

model bind for type like datetime guid always failed. #18

Closed
Eilyyyy opened this issue Jul 27, 2017 · 9 comments
Closed

model bind for type like datetime guid always failed. #18

Eilyyyy opened this issue Jul 27, 2017 · 9 comments

Comments

@Eilyyyy
Copy link

Eilyyyy commented Jul 27, 2017

when you send message type that can simplely convert from string like guid, datetime, you always get a format exception that not valid value for this type. the problem is than you publish message always use json string , but you can't just use typeconvert convert json string to a object.

@Eilyyyy
Copy link
Author

Eilyyyy commented Jul 27, 2017

i think you can fix this problems by serialize simple type of message just use to string method, or always treat as complex type.

@yang-xiaodong
Copy link
Member

yang-xiaodong commented Jul 27, 2017

Hi @Eilyyyy , thanks for your feedback.

I have already fixed this bug at commit 297cecf.

I will release a new version later.

@Eilyyyy
Copy link
Author

Eilyyyy commented Jul 27, 2017

tim 20170727155751
i'm sure i'm on this commit but the problem is still here.

@yang-xiaodong
Copy link
Member

yang-xiaodong commented Jul 27, 2017

you mean that you are using this void Publish<T>(string name, T contentObj) overloaded method to publish message with datetime or guid?

@Eilyyyy
Copy link
Author

Eilyyyy commented Jul 27, 2017

yes, PublishAsync

@Eilyyyy
Copy link
Author

Eilyyyy commented Jul 27, 2017

i think the problem is here
var isComplexType = !TypeDescriptor.GetConverter(type).CanConvertFrom(typeof(string));

this type can convert from string , so you treat it as simple type.you serialize a 134 you got 123, but you serialize a guid you got a "xxxx-xxxxxx-xxxx", notice you have a quotation marks and this cause you can't convert from the content.

@yang-xiaodong
Copy link
Member

Yes, I didn't consider this kind of situation, I will fix it later, thank you.

yang-xiaodong added a commit that referenced this issue Jul 28, 2017
@yang-xiaodong
Copy link
Member

Hi @Eilyyyy
I fixed this problem and removed the overloaded method of publishing string content.

@yang-xiaodong
Copy link
Member

fixed at v1.1.0

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants