Facebook C#SDK-.NET 3.5及更高版本动态物体 [英] Facebook C# SDK - .NET 3.5 & Dynamic objects
问题描述
我已经下载了用于Facebook的Graph C#SDK,这些示例非常有用并且易于理解,但是当我尝试将动态对象类型用作FacebookApp.Get("me")调用的返回对象时,我感到很困惑.
I have downloaded the Graph C# SDK for facebook, the examples are very helpful and easy to understand however i come unstuck when trying to use the dynamic object type as the return object for a FacebookApp.Get("me") call.
我以前从未使用过动力学,所以我做了一些reasearch,看来它们是Visual Studio 2010的新功能,这是我正在使用的版本,但由于生产环境的缘故,我无法使用最新的框架...
I'v never used dynamics before so i did a bit of reasearch and it seems they are new to Visual Studio 2010, which is the version i am using but i cant use the latest framework because of my production environment...
有没有一种我可以代替使用的类型,或者是否有使用3.5框架进行此操作的其他方法?这是框架二进制文件随附的源文件中的示例.
Is there a type i can use instead or is there a different way to go about this using the 3.5 framework? here is an example from the source files provided with the binary for the framework.
dynamic myInfo = app.Get("me");
lblTitle.Text = myInfo.name;
我收到一条错误消息,指出我可能缺少动态类型的装配参考.
I get an error stating that i may be missing an assembely reference for type dynamic.
非常感谢所有帮助!期待着使用此SDK!
Any and all help is greatly apreciated! looking forward to getting to grips with this SDK!!
推荐答案
如果要使用强类型对象,则有一种非常简单的方法.参见此处: https://gist.github.com/906471
If you want strongly typed objects there is a very easy way to do that. See here: https://gist.github.com/906471
var fb = new FacebookClient("access_token");
var result = fb.Get<FBUser>("/me");
string name = result.Name;
MessageBox.Show("Hi " + name);
[DataContract]
public class FBUser {
[DataMember(Name="name")]
public string Name { get; set; }
[DataMember(Name="first_name")]
public string FirstName { get; set; }
}
这篇关于Facebook C#SDK-.NET 3.5及更高版本动态物体的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!