コード例 #1
0
    IEnumerator DoLoadImage(FacebookEntity person)
    {
        if (!person.isLoading) {

            person.isLoading = true;
            Debug.Log("\nTrying to loadimage: " + person.Id);
            WWW url = new WWW(person.ImageUrl);
            yield return url;
            Debug.Log("\nImage loaded: " + person.Id);

            person.Image = Sprite.Create(url.texture, new Rect(0, 0, 128, 128), new Vector2(0.5f, 0.5f));
            List<Image> toDelete = new List<Image>();

            foreach (KeyValuePair<Image, string> pair in queue) {
                if (pair.Value == person.Id) {
                    pair.Key.sprite = person.Image;
                    toDelete.Add(pair.Key);
                }
            }

            foreach (Image delete in toDelete) {
                queue.Remove(delete);
            }
        }
    }
コード例 #2
0
 public void LoadImage(FacebookEntity person, Image loadIn)
 {
     Debug.Log("\nTrying to open image: " + person.Id);
     if (person.Image == null) {
         if (!queue.ContainsKey(loadIn)){
             queue.Add(loadIn, person.Id);
         }
         StartCoroutine(DoLoadImage(person));
     }
     else {
         loadIn.sprite = person.Image;
     }
 }
コード例 #3
0
        public void Search()
        {
            Thread th = new Thread(() => {
                FacebookSearch facebookSearch = new FacebookSearch();
                facebookSearch.SearchFile(ServiceManager.Instence().FacebookClient,
                                          t => {
                    FacebookEntity facebookEntity = new FacebookEntity()
                    {
                        Url = t.Url
                    };
                    System.Windows.Application.Current.Dispatcher.Invoke(new Action(() =>
                    {
                        _detailVM.Add(facebookEntity);
                    }));
                });
            });

            th.Name = "SearchFacebookThread";
            th.Start();
        }
コード例 #4
0
        public async Task <ActionResult> ExternalLoginCallback()
        {
            Account account = null;
            var     info    = await AuthenticationManager.GetExternalLoginInfoAsync();

            if (info == null)
            {
                return(RedirectToAction("Index", "Home"));
            }
            if (info.Login.LoginProvider == "Facebook")
            {
                FacebookClient fb          = new FacebookClient();
                var            identity    = AuthenticationManager.GetExternalIdentity(DefaultAuthenticationTypes.ExternalCookie);
                var            accessToken = identity.FindFirstValue(FacebookAccessToken);
                fb.AccessToken = accessToken;
                var            facebookInfo   = fb.Get(ConfigurationManager.AppSettings["FacebookUri"]);
                FacebookEntity facebookEntity = JsonConvert.DeserializeObject <FacebookEntity>(facebookInfo.ToString());
                account           = new Account();
                account.Id        = facebookEntity.Id;
                account.Name      = facebookEntity.Name;
                account.Email     = facebookEntity.Email;
                account.FirstName = facebookEntity.first_name;
                account.LastName  = facebookEntity.last_name;
            }
            else if (info.Login.LoginProvider == "Google")
            {
                string       googleInfo   = info.ExternalIdentity.Claims.FirstOrDefault(c => c.Type == "GoogleInfo").Value;
                GoogleEntity ObjectGoogle = JsonConvert.DeserializeObject <GoogleEntity>(googleInfo);
                account           = new Account();
                account.Id        = ObjectGoogle.id;
                account.Name      = ObjectGoogle.name;
                account.Email     = ObjectGoogle.email;
                account.FirstName = ObjectGoogle.given_name;
                account.LastName  = ObjectGoogle.family_name;
            }

            return(View("ExternalLoginConfirmation", account));
        }
コード例 #5
0
	FacebookEntity ConvertObjectToEntity(object friend){
		var fd = (Dictionary<string, object>)friend;
        string Name = (string)fd["name"];

		FacebookEntity entity = new FacebookEntity();
		entity.Id = fd["id"].ToString();
        entity.LastName = Name.Substring(0, Name.IndexOf(' '));
        entity.FirstName = Name.Substring(Name.IndexOf(' ') + 1, Name.Length - Name.IndexOf(' ') - 1);
		var pictureDict = ((Dictionary<string, object>)(fd["picture"]));
		var pictureDataDict = ((Dictionary<string, object>)(pictureDict["data"]));
		entity.ImageUrl = (string)pictureDataDict["url"];
		return entity;
	}