PageRenderTime 56ms CodeModel.GetById 21ms RepoModel.GetById 1ms app.codeStats 0ms

/Source/facebook.Linq/FacebookDataContext.cs

https://bitbucket.org/assaframan/facebooklinq
C# | 301 lines | 142 code | 34 blank | 125 comment | 3 complexity | fcf924c5af2606dfae4fbc2bec524ea3 MD5 | raw file
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using facebook.Schema;
  6. using facebook.Web;
  7. using facebook.Linq;
  8. namespace facebook
  9. {
  10. /// <summary>
  11. /// The Facebook Database. Queries on tables on an instance will be done against the facebook servers.
  12. /// </summary>
  13. public class FacebookDataContext : FqlDataContext
  14. {
  15. /// <summary>
  16. /// Creates a FacebookDataContext using the specified api
  17. /// </summary>
  18. /// <param name="api"></param>
  19. public FacebookDataContext(API api)
  20. : base(api)
  21. {
  22. }
  23. /// <summary>
  24. /// Creates a FacebookDataContext using the FacebookSession.Current Api.
  25. /// </summary>
  26. public FacebookDataContext()
  27. : this( GetDefaultApi())
  28. {
  29. }
  30. static API GetDefaultApi()
  31. {
  32. var context = FacebookContext.Current;
  33. if(context!=null && context.Session!=null && context.Session.Api!=null)
  34. return context.Session.Api;
  35. return new API();
  36. }
  37. public long uid
  38. {
  39. get
  40. {
  41. return Api.uid;
  42. }
  43. }
  44. /// <summary>
  45. /// The FQL album table. Query this table to return information about a photo album.
  46. /// </summary>
  47. public FqlTable<album> album
  48. {
  49. get
  50. {
  51. return GetTable<album>();
  52. }
  53. }
  54. /// <summary>
  55. /// The FQL cookies table. Query this table to return information about a cookie.
  56. /// </summary>
  57. public FqlTable<cookie> cookie
  58. {
  59. get
  60. {
  61. return GetTable<cookie>();
  62. }
  63. }
  64. /// <summary>
  65. /// The FQL event table. Query this table to return information about an event.
  66. /// </summary>
  67. public FqlTable<facebookevent> facebookevent
  68. {
  69. get
  70. {
  71. return GetTable<facebookevent>();
  72. }
  73. }
  74. /// <summary>
  75. /// The FQL event_member table. Query this table to return information about a user's status for an event.
  76. /// </summary>
  77. public FqlTable<event_member> event_member
  78. {
  79. get
  80. {
  81. return GetTable<event_member>();
  82. }
  83. }
  84. /// <summary>
  85. /// The FQL friend table. Query this table to determine whether two users are linked together as friends.
  86. /// </summary>
  87. public FqlTable<friend_info> friend_info
  88. {
  89. get
  90. {
  91. return GetTable<friend_info>();
  92. }
  93. }
  94. ///// <summary>
  95. ///// The FQL friend_request table. Query this table either to determine which users have sent friend requests to the logged-in user or to query whether a friend request has been sent from the logged-in user to a specific user. You can run this query only when the uid_to is set to the logged-in user or when uid_from is set to the logged-in user and uid_to is set to a specific user.
  96. ///// </summary>
  97. //public FqlTable<FriendRequest> FriendRequests
  98. //{
  99. // get
  100. // {
  101. // return GetTable<FriendRequest>();
  102. // }
  103. //}
  104. /// <summary>
  105. /// The FQL friendlist table. Query this table to return any friend lists owned by the specified user. You can run this query only when the owner is set to the logged-in user. You can store flids, but you cannot expose this information to anyone but the logged in user, as it is private.
  106. /// </summary>
  107. public FqlTable<friendlist> friendlist
  108. {
  109. get
  110. {
  111. return GetTable<friendlist>();
  112. }
  113. }
  114. /// <summary>
  115. /// The FQL group table. Query this table to return information about a group.
  116. /// </summary>
  117. public FqlTable<group> group
  118. {
  119. get
  120. {
  121. return GetTable<group>();
  122. }
  123. }
  124. /// <summary>
  125. /// The FQL group_member table. Query this table to return information about the members of a group.
  126. /// </summary>
  127. public FqlTable<group_member> group_member
  128. {
  129. get
  130. {
  131. return GetTable<group_member>();
  132. }
  133. }
  134. /// <summary>
  135. /// The FQL listing table. Query this table to return information about a listing in Facebook Marketplace.
  136. /// </summary>
  137. public FqlTable<listing> listing
  138. {
  139. get
  140. {
  141. return GetTable<listing>();
  142. }
  143. }
  144. /// <summary>
  145. /// The FQL metrics table. Query this table to retrieve metrics about your application. All metrics are identified by a name, and a period over which they've been collected (e.g. one day or seven days).
  146. /// </summary>
  147. public FqlTable<metrics> metrics
  148. {
  149. get
  150. {
  151. return GetTable<metrics>();
  152. }
  153. }
  154. /// <summary>
  155. /// The FQL page table. Query this table to return information about a Facebook Page.
  156. /// </summary>
  157. public FqlTable<page> page
  158. {
  159. get
  160. {
  161. return GetTable<page>();
  162. }
  163. }
  164. ///// <summary>
  165. ///// The FQL page_admin table. Query this table to return information about the admin of a Facebook Page.
  166. ///// </summary>
  167. //public FqlTable<FacebookPageAdmin> PageAdmins
  168. //{
  169. // get
  170. // {
  171. // return GetTable<FacebookPageAdmin>();
  172. // }
  173. //}
  174. ///// <summary>
  175. ///// The FQL page_fan table. Query this table to return information about the fan of a Facebook Page.
  176. ///// </summary>
  177. //public FqlTable<FacebookPageFan> PageFans
  178. //{
  179. // get
  180. // {
  181. // return GetTable<FacebookPageFan>();
  182. // }
  183. //}
  184. /// <summary>
  185. /// The FQL photo table. Query this table to return information about a photo.
  186. /// </summary>
  187. public FqlTable<photo> photo
  188. {
  189. get
  190. {
  191. return GetTable<photo>();
  192. }
  193. }
  194. /// <summary>
  195. /// The FQL photo_tag table. Query this table to return information about a photo tag.
  196. /// </summary>
  197. public FqlTable<photo_tag> photo_tag
  198. {
  199. get
  200. {
  201. return GetTable<photo_tag>();
  202. }
  203. }
  204. ///// <summary>
  205. ///// The FQL standard_user_info table. Query this table to return standard information about a user, for use when you need analytic information only. Don't display this information to any users. If you need to display information to other users, query the user FQL table instead.
  206. ///// </summary>
  207. //public FqlTable<standard_user_info> StandardUsers
  208. //{
  209. // get
  210. // {
  211. // return GetTable<StandardUserInfo>();
  212. // }
  213. //}
  214. /// <summary>
  215. /// The FQL user table. Query this table to return detailed information from a user's profile. If you need user information for analytic purposes, query the standard_user_info table instead.
  216. /// </summary>
  217. public FqlTable<user> user
  218. {
  219. get
  220. {
  221. return GetTable<user>();
  222. }
  223. }
  224. /// <summary>
  225. /// The current Facebook user (null if logged off)
  226. /// </summary>
  227. public user CurrentUser
  228. {
  229. get
  230. {
  231. return GetObject<user>(Api.uid, true);
  232. }
  233. }
  234. #region TODO
  235. ///// <summary>
  236. ///// The FQL comment table. Query this table to obtain comments associated with an fb:comments/Feed story comment XID.
  237. ///// </summary>
  238. //public FqlTable<Comment> Comments
  239. //{
  240. // get
  241. // {
  242. // return GetTable<Comment>();
  243. // }
  244. //}
  245. ///// <summary>
  246. ///// The FQL friendlist_member table. Query this table to determine which users are members of a friend list. You can run this query only when the flid is owned by the logged-in user. You cannot expose this information to anyone but the logged in user, as it is private. In addition, you cannot store flids.
  247. ///// </summary>
  248. //public FqlTable<FriendListMember> FriendListMembers
  249. //{
  250. // get
  251. // {
  252. // return GetTable<FriendListMember>();
  253. // }
  254. //}
  255. ///// <summary>
  256. ///// The FQL permissions table. Query this table to return the extended permissions the current user has granted to the application.
  257. ///// </summary>
  258. //public FqlTable<UserPermission> UserPermissions
  259. //{
  260. // get
  261. // {
  262. // return GetTable<UserPermission>();
  263. // }
  264. //}
  265. #endregion
  266. }
  267. }