-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathPlacesCollection.cs
More file actions
53 lines (45 loc) · 1.57 KB
/
Copy pathPlacesCollection.cs
File metadata and controls
53 lines (45 loc) · 1.57 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using FacebookCore.Entities;
using Newtonsoft.Json.Linq;
using System;
using System.Threading.Tasks;
namespace FacebookCore.Collections
{
public class PlacesCollection : FacebookCollection<Place>
{
public PlacesCollection(FacebookClient client, string query, string token, FacebookCursor cursor = null) : base(client, query, token, PlaceMapper, cursor)
{
}
public new async Task<PlacesCollection> BeforeAsync()
{
FacebookCollection<Place> collection = await base.BeforeAsync();
return (PlacesCollection)collection;
}
public new async Task<PlacesCollection> AfterAsync()
{
FacebookCollection<Place> collection = await base.AfterAsync();
return (PlacesCollection)collection;
}
private static Place PlaceMapper(JToken data)
{
Place place = new Place
{
Id = data["id"]?.ToString(),
Name = data["name"]?.ToString()
};
if (data["checkins"] != null)
{
place.Checkins = Convert.ToInt32(data["checkins"]);
}
if (data["picture"] != null)
{
place.Picture = new Picture()
{
Url = data["picture"]["data"]["url"].ToString(),
Width = Convert.ToInt32(data["picture"]["data"]["width"]),
Height = Convert.ToInt32(data["picture"]["data"]["height"])
};
}
return place;
}
}
}