Browse files

* AddAccessTokenIfRequriedTo(ref ..)

  • Loading branch information...
1 parent 5ea7ab7 commit 57c15d9ceec5c0fe63c98554595a427c9472bf8b @prabirshrestha committed Jun 30, 2010
View
17 src/LinqToFacebook.Tests/FacebookContext/GenericWebRequests/GetTests.cs
@@ -1,5 +1,5 @@
+using System.Linq;
using Xunit;
-using LinqToFacebook.Utilities;
namespace LinqToFacebook.Tests.FacebookContextTests.GenericWebRequests
{
@@ -24,5 +24,20 @@ public void Get_UserInfo_By_Username_Tests()
var firstName = response.ToJToken().Value<string>("first_name");
Assert.Equal("Prabir", firstName);
}
+
+ [Fact]
+ public void Linq_GetUserById()
+ {
+ // Arrange
+ var query = from user in _fbContext.Users
+ where user.ID == "100001241534829"
+ select user;
+
+ // Act
+ var u = query.First();
+
+ // Assert
+ Assert.Equal("Jimmi Hendrix", u.Name);
+ }
}
}
View
21 src/LinqToFacebook.Tests/FacebookContext/WriteFeedTests.cs
@@ -1,8 +1,4 @@
-using System;
-using System.Collections.Generic;
-using System.Linq;
-using System.Text;
-using Xunit;
+using Xunit;
namespace LinqToFacebook.Tests.GenericWebRequests
{
@@ -30,21 +26,6 @@ public void WriteToWall()
// Assert
Assert.Equal(message, post.Message);
}
-
- [Fact]
- public void Linq_GetUserById()
- {
- // Arrange
- var query = from user in _fbContext.Users
- where user.ID == "100001241534829"
- select user;
-
- // Act
- var u = query.First();
-
- // Assert
- Assert.Equal("Jimmi Hendrix", u.Name);
- }
}
#endif
View
2 src/LinqToFacebook.Tests/Helpers.cs
@@ -4,6 +4,6 @@ namespace LinqToFacebook.Tests
{
public class Helpers
{
- public static string AccessToken { get { throw new NotImplementedException(); } }
+ public static string AccessToken { get { return ""; } }
}
}
View
4 src/LinqToFacebook/FacebookContext/FacebookContext.cs
@@ -28,7 +28,7 @@ public FacebookContext()
public FacebookContext(FacebookSettings facebookSettings)
{
Settings = facebookSettings;
- _facebookQueryFactory = new FacebookQueryFactory();
+ InitLinqExtender();
}
#region Helpers
@@ -39,7 +39,7 @@ private void AssertRequiresAccessToken()
throw new AccessTokenRequiredException();
}
- private void AddAccessTokenIfRequriedTo(IDictionary<string, string> parameters)
+ private void AddAccessTokenIfRequriedTo(ref IDictionary<string, string> parameters)
{
if (string.IsNullOrEmpty(Settings.AccessToken))
return;
View
14 src/LinqToFacebook/FacebookContext/LinqExtenderStuffs.cs
@@ -1,11 +1,23 @@
using LinqToFacebook.Queries;
+using LinqExtender.Configuration;
namespace LinqToFacebook
{
public partial class FacebookContext
{
+ private void InitLinqExtender()
+ {
+ //Extender.Settings
+ // .For<FacebookUser>()
+ // .Begin
+ // .Property(x => x.ID).MarkAsUnique
+ // .End
+ // .InstantiateIn(this);
+ _facebookQueryFactory = new FacebookQueryFactory();
+ }
+
private FacebookQueryFactory _facebookQueryFactory;
-
+
private FacebookUserQuery _facebookUserQuery;
public FacebookUserQuery Users
{
View
12 src/LinqToFacebook/FacebookContext/Request.cs
@@ -12,7 +12,7 @@ public partial class FacebookContext
public string Get(string path, IDictionary<string, string> parameters)
{
- AddAccessTokenIfRequriedTo(parameters);
+ AddAccessTokenIfRequriedTo(ref parameters);
var result = WebRequestHelpers.Get(string.Format(GraphUrl, path), parameters, Settings.CompressHttp,
Settings.UserAgent);
@@ -40,7 +40,7 @@ public T Get<T>(string path, IDictionary<string, string> parameters)
/// <returns>Returns true if successfully executed, otherwise false.</returns>
public bool TryGet(string path, IDictionary<string, string> parameters, out string result)
{
- AddAccessTokenIfRequriedTo(parameters);
+ AddAccessTokenIfRequriedTo(ref parameters);
result = WebRequestHelpers.Get(string.Format(GraphUrl, path), parameters, Settings.CompressHttp,
Settings.UserAgent);
@@ -55,7 +55,7 @@ public bool TryGet(string path, IDictionary<string, string> parameters, out stri
public bool TryGet<T>(string path, IDictionary<string, string> parameters, out T obj)
{
- AddAccessTokenIfRequriedTo(parameters);
+ AddAccessTokenIfRequriedTo(ref parameters);
string json = WebRequestHelpers.Get(string.Format(GraphUrl, path), parameters, Settings.CompressHttp,
Settings.UserAgent);
@@ -86,7 +86,7 @@ public bool TryGet<T>(string path, IDictionary<string, string> parameters, out T
public string Post(string path, IDictionary<string, string> parameters)
{
- AddAccessTokenIfRequriedTo(parameters);
+ AddAccessTokenIfRequriedTo(ref parameters);
var result = WebRequestHelpers.Post(string.Format(GraphUrl, path), parameters, Settings.CompressHttp,
Settings.UserAgent);
@@ -107,7 +107,7 @@ public T Post<T>(string path, IDictionary<string, string> parameters)
public bool TryPost(string path, IDictionary<string, string> parameters, out string result)
{
- AddAccessTokenIfRequriedTo(parameters);
+ AddAccessTokenIfRequriedTo(ref parameters);
result = WebRequestHelpers.Post(string.Format(GraphUrl, path), parameters, Settings.CompressHttp,
Settings.UserAgent);
@@ -122,7 +122,7 @@ public bool TryPost(string path, IDictionary<string, string> parameters, out str
public bool TryPost<T>(string path, IDictionary<string, string> parameters, out T obj)
{
- AddAccessTokenIfRequriedTo(parameters);
+ AddAccessTokenIfRequriedTo(ref parameters);
string json = WebRequestHelpers.Post(string.Format(GraphUrl, path), parameters, Settings.CompressHttp,
Settings.UserAgent);
View
144 src/LinqToFacebook/Objects/User.cs
@@ -1,88 +1,88 @@
using System.Runtime.Serialization;
-using LinqExtender.Interfaces;
-
-namespace LinqToFacebook
-{
- /// <summary>
- /// A facebook user profile.
- /// </summary>
- /// <remarks>
- /// http://developers.facebook.com/docs/reference/api/user
- /// </remarks>
- public class FacebookUser : FacebookObject
- {
- /// <summary>
- /// The user's first name. (first_name)
+using LinqExtender.Interfaces;
+
+namespace LinqToFacebook
+{
+ /// <summary>
+ /// A facebook user profile.
+ /// </summary>
+ /// <remarks>
+ /// http://developers.facebook.com/docs/reference/api/user
+ /// </remarks>
+ public class FacebookUser : FacebookObject
+ {
+ /// <summary>
+ /// The user's first name. (first_name)
/// </summary>
- [DataMember(Name = "first_name")]
- public string FirstName { get; set; }
- /// <summary>
- /// The user's last name. (last_name)
+ [DataMember(Name = "first_name")]
+ public string FirstName { get; set; }
+ /// <summary>
+ /// The user's last name. (last_name)
/// </summary>
- [DataMember(Name = "last_name")]
- public string LastName { get; set; }
- /// <summary>
- /// The user's full name. (name)
+ [DataMember(Name = "last_name")]
+ public string LastName { get; set; }
+ /// <summary>
+ /// The user's full name. (name)
/// </summary>
- [DataMember(Name = "name")]
- public string Name { get; set; }
- /// <summary>
- /// A link to the user's profile. (link)
+ [DataMember(Name = "name")]
+ public string Name { get; set; }
+ /// <summary>
+ /// A link to the user's profile. (link)
/// </summary>
- [DataMember(Name = "link")]
- public string Link { get; set; }
- /// <summary>
- /// The user's blurb that appears under the profile picture. (about)
+ [DataMember(Name = "link")]
+ public string Link { get; set; }
+ /// <summary>
+ /// The user's blurb that appears under the profile picture. (about)
/// </summary>
- [DataMember(Name = "about")]
- public string About { get; set; }
- /// <summary>
- /// The user's birthday. (birthday)
+ [DataMember(Name = "about")]
+ public string About { get; set; }
+ /// <summary>
+ /// The user's birthday. (birthday)
/// </summary>
- [DataMember(Name = "birthday")]
- public string Birthday { get; set; }
- // todo: work,education
- /// <summary>
- /// The proxied or contact email address granted by the user. (email)
+ [DataMember(Name = "birthday")]
+ public string Birthday { get; set; }
+ // todo: work,education
+ /// <summary>
+ /// The proxied or contact email address granted by the user. (email)
/// </summary>
- [DataMember(Name = "email")]
- public string Email { get; set; }
- /// <summary>
- /// A link to the user's personal website. (website)
+ [DataMember(Name = "email")]
+ public string Email { get; set; }
+ /// <summary>
+ /// A link to the user's personal website. (website)
/// </summary>
- [DataMember(Name = "website")]
- public string Website { get; set; }
- /// <summary>
- /// The user's hometown. (hometown)
+ [DataMember(Name = "website")]
+ public string Website { get; set; }
+ /// <summary>
+ /// The user's hometown. (hometown)
/// </summary>
- [DataMember(Name = "hometown")]
- public string HomeTown { get; set; }
- /// <summary>
- /// The user's current location. (location)
+ [DataMember(Name = "hometown")]
+ public string HomeTown { get; set; }
+ /// <summary>
+ /// The user's current location. (location)
/// </summary>
- [DataMember(Name = "location")]
- public string Location { get; set; }
- // todo: gender, interested_in, meeting_for, relationshipe_status
- /// <summary>
- /// The user's religion. (religion)
+ [DataMember(Name = "location")]
+ public string Location { get; set; }
+ // todo: gender, interested_in, meeting_for, relationshipe_status
+ /// <summary>
+ /// The user's religion. (religion)
/// </summary>
- [DataMember(Name = "religion")]
- public string Religion { get; set; }
- /// <summary>
- /// The user's political view. (political)
+ [DataMember(Name = "religion")]
+ public string Religion { get; set; }
+ /// <summary>
+ /// The user's political view. (political)
/// </summary>
- [DataMember(Name = "political")]
- public string PoliticalView { get; set; }
- /// <summary>
- /// The user's account verification status (verified)
+ [DataMember(Name = "political")]
+ public string PoliticalView { get; set; }
+ /// <summary>
+ /// The user's account verification status (verified)
/// </summary>
- [DataMember(Name = "verified")]
- public bool IsVerified { get; set; }
- // todo: significant_other
- /// <summary>
- /// The user's timezone. (timezone)
+ [DataMember(Name = "verified")]
+ public bool IsVerified { get; set; }
+ // todo: significant_other
+ /// <summary>
+ /// The user's timezone. (timezone)
/// </summary>
- [DataMember(Name = "timezone")]
- public int TimeZone { get; set; }
- }
+ [DataMember(Name = "timezone")]
+ public int TimeZone { get; set; }
+ }
}
View
1 src/LinqToFacebook/Repositories/IFacebookUserRepository.cs
@@ -1,3 +1,4 @@
+using System;
using LinqExtender.Interfaces;
namespace LinqToFacebook.Repositories

0 comments on commit 57c15d9

Please sign in to comment.