Access SDK object for Facebook C # Object using .NET 3.5 API?

Consider the following in .NET 3.5 (using the Bin \ Net35 \ Facebook * .dll assemblies):

using Facebook; var app = new FacebookApp(); var result = app.Get("me"); // want to access result properties with no dynamic 

... in the absence of the C # 4.0 dynamic keyword, this provides only the general members of the object .
What is the best way to access the facebook properties of this result object?

Are there any helper or utility methods or stronger types in facebook's C # SDK, or should I use standard .NET mapping methods?

+2
source share
3 answers

This code example shows using 3.5 without using the C # dynamic keyword:

 // Using IDictionary<string, object> (.Net 3.5) var client = new FacebookClient(); var me = (IDictionary<string,object>)client.Get("me"); string firstName = (string)me["first_name"]; string lastName = (string)me["last_name"]; string email = (string)me["email"]; 
+5
source
 var accesstoken = Session["AccessToken"].ToString(); var client = new FacebookClient(accesstoken); dynamic result = client.Get("me", new { fields = "name,id,email" }); Details details = new Details(); details.Id = result.id; details.Name = result.name; details.Email = result.email; 
0
source

You can also create a facade object around an IDictionary, as described here .

-1
source

Source: https://habr.com/ru/post/1335330/


All Articles