简体   繁体   English

从NameValueCollection读取结构

[英]Reading struct from NameValueCollection

I am working on a payment processor class right now and I have hit a roadblock. 我正在研究支付处理器类,我遇到了障碍。 I am using the FastSpring e-commerce service and they have a nice set of tools, but I am stuck on one thing. 我正在使用FastSpring电子商务服务,他们有一套很好的工具,但我坚持一件事。

For PayPal IPN, to get the person's first name (this is in C#/ASP code) I would do this: 对于PayPal IPN,要获取该人的名字(这是在C#/ ASP代码中),我会这样做:

base.Context.Request.Params["first_name"]

With FastSpring, they seem to store the information within a structure, as seen here in "customer": http://nvsx.net/i/c2252.png 使用FastSpring,他们似乎将信息存储在一个结构中,如“客户”中所示: http//nvsx.net/i/c2252.png

How would I modify my code to properly create that structure from the HTTP post context? 如何修改我的代码以从HTTP post上下文中正确创建该结构?

Updates: 更新:

NameValueCollection keys: http://pastie.org/1346312 NameValueCollection键: http//pastie.org/1346312

Customer Key Value: {0} --> {1}Customercom.brightmarket.api.variable.v1.contact.ContactVariable@175d7aa 客户关键值: {0} --> {1}Customercom.brightmarket.api.variable.v1.contact.ContactVariable@175d7aa

It looks like it's already a proper object, no? 看起来它已经是一个合适的对象,不是吗? You should just have to cast it. 你应该只需要施放它。

Have you tried something like 你尝试过类似的东西吗?

var contact = (ContactVariable)Context.Request.Params[str];

and then using the members of the contact variable? 然后使用联系变量的成员?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM