예제 #1
0
파일: Templates.cs 프로젝트: tms/StackFlair
        public static BadgeCounts GetBadgeCounts(Site site, int userId)
        {
            var client   = new StackyClient(cfg.AppSettings["ApiVersion"], cfg.AppSettings["ApiKey"], site, new UrlClient(), new JsonProtocol());
            var siteUser = client.GetUser(userId);

            return(siteUser.BadgeCounts);
        }
예제 #2
0
    public static Guid GetAssociationId(int userID, StackSite site)
    {
        var stackAuthClient = new StackAuthClient(new UrlClient(), new JsonProtocol());
        var sites           = stackAuthClient.GetSites();
        var siteClient      = new StackyClient(version, apiKey, sites.Where(s => s.Name == site.Name).Single(), new UrlClient(), new JsonProtocol());
        var associationId   = siteClient.GetUser(userID).AssociationId;

        return(associationId);
    }
예제 #3
0
파일: Program.cs 프로젝트: tms/StackFlair
        private static IEnumerable <Site> GetSites()
        {
            var stackAuthClient = new StackAuthClient(new UrlClient(), new JsonProtocol());
            var sites           = stackAuthClient.GetSites().Where(s => s.State != SiteState.Linked_Meta);
            var siteCreation    = new Dictionary <DateTime, Site>();

            foreach (var site in sites)
            {
                var siteClient = new StackyClient(cfg.Default.ApiVersion, cfg.Default.ApiKey, site, new UrlClient(), new JsonProtocol());
                var user       = siteClient.GetUser(-1);
                siteCreation.Add(user.CreationDate, site);
            }
            sites = siteCreation.OrderBy(s => s.Key).Select(s => s.Value);

            return(sites);
        }