Ejemplo n.º 1
0
 void Process(ChirperId chirperId, FollowerId followerId, Action<MyFollows, Chirper> updateMyFollows, Action<MyFollowers, Follower> updateMyFollowers)
 {
     var chirper = _chirperRepository.GetById(chirperId);
     var follower = _followerRepository.GetById(followerId);
     UpdateMyFollowers(chirper, follower, updateMyFollowers);
     UpdateMyFollows(follower, chirper, updateMyFollows);
 }
Ejemplo n.º 2
0
        /// <summary>
        /// Gets all followers ids and then inflates follower objects for each follower
        /// </summary>
        /// <param name="tokens"></param>
        /// <returns></returns>
        public List <User> GetAllFollowers(OAuthTokens tokens)
        {
            long          cursor           = -1;
            List <string> allIds           = new List <string>();
            string        responseText     = string.Empty;
            List <User>   twitterFollowers = new List <User>();

            while (cursor != 0)
            {
                responseText = Request.ExecuteAuthenticatedWebRequest(string.Format("{0}/followers/ids.json?user_id=14949454&include_entities=true&cursor=" + cursor, ApiUrl), tokens);

                FollowerId twitterFollowerIds = Request.Deserialize <FollowerId>(responseText);
                if (!object.Equals(null, twitterFollowerIds.ids))
                {
                    allIds.AddRange(twitterFollowerIds.ids);
                    cursor = twitterFollowerIds.next_cursor.Value;
                }
                Thread.Sleep(60000);                //sleep to avoid rate limit
            }

            int curStep = 0;

            while (curStep < allIds.Count)
            {
                responseText = Request.ExecuteAuthenticatedWebRequest(string.Format("{0}/users/lookup.json?include_entities=true&user_id={1}", ApiUrl, string.Join(",", allIds.Skip(curStep).Take(100))), tokens);
                twitterFollowers.AddRange(Request.Deserialize <List <User> >(responseText));
                curStep = twitterFollowers.Count;
                Thread.Sleep(6000);                 //sleep to avoid rate limit
            }

            return(twitterFollowers);
        }
Ejemplo n.º 3
0
 private FollowerSkill MapSkill(FollowerId followerId, FollowerSkillDto input)
 {
     return(new FollowerSkill
     {
         Id = new FollowerSkillId(followerId, input.Slug),
         Name = input.Name,
         Level = input.Level,
         IconUrl = input.Icon,
         TooltipUrl = input.TooltipUrl
     });
 }
Ejemplo n.º 4
0
 public override int GetHashCode()
 {
     unchecked {
         const int randomPrime = 397;
         int       hashCode    = Id.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ UserId.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ FollowerId.GetHashCode();
         hashCode = (hashCode * randomPrime) ^ FollowedAt.GetHashCode();
         return(hashCode);
     }
 }
Ejemplo n.º 5
0
        private HeroItemFollower MapFollowerItem(FollowerId followerId, DetailedItemDto input)
        {
            var slot   = EnumConversionHelper.ItemFollowerSlotFromString(input.Slots);
            var output = new HeroItemFollower
            {
                Slot     = slot,
                Follower = followerId
            };

            MapCustomizableItem(input, output);
            return(output);
        }
Ejemplo n.º 6
0
        private IEnumerable <FollowerSkill> MapSkills(FollowerId followerId, IEnumerable <FollowerSkillDto> inputs)
        {
            var outputs = new List <FollowerSkill>();

            foreach (var input in inputs)
            {
                var output = MapSkill(followerId, input);
                outputs.Add(output);
            }

            return(outputs);
        }
Ejemplo n.º 7
0
 public FollowerSkillId(FollowerId id, string slug)
 {
     Id   = id;
     Slug = slug;
 }
Ejemplo n.º 8
0
        public async Task <Follower> GetFollowerAsync(IAuthenticationScope authenticationScope, FollowerId followerId)
        {
            var mapper       = new FollowerMapper();
            var followerSlug = followerId.ToString().ToLower();

            using (var client = CreateClient(authenticationScope))
            {
                var follower = await client.GetFollowerAsync(followerSlug);

                return(mapper.Map(follower));
            }
        }
Ejemplo n.º 9
0
 public FollowerFollows(FollowerId follower) : this()
 {
     Follower = follower;
 }
Ejemplo n.º 10
0
 public static Follower Get(FollowerId id)
 {
     return GetAll().SingleOrDefault(c => c.FollowerId == id);
 }
Ejemplo n.º 11
0
 public MyFollows(FollowerId follower) : this()
 {
     FollowerId = follower;
 }
Ejemplo n.º 12
0
        void Follow(IContainer container, FollowerId follower, ChirperId chirperId)
        {
            var chirperFollowed = new ChirperFollowed()
                                    {
                                        EventSourceId = follower,
                                        Chirper = chirperId
                                    };

            var domainSubscriber = container.Get<domainFollow.FollowSubscriber>();
            domainSubscriber.Process(chirperFollowed);
            var viewSubscriber = container.Get<viewFollow.FollowSubscriber>();
            viewSubscriber.Process(chirperFollowed);
        }
Ejemplo n.º 13
0
 public void RemoveFollower(FollowerId followerId)
 {
     if(_followers.Contains(followerId))
         _followers.Remove(followerId);
 }
Ejemplo n.º 14
0
 public void AddFollower(FollowerId followerId)
 {
     if(!_followers.Contains(followerId))
         _followers.Add(followerId);
 }