protected override void ConfigureApplicationContainer(TinyIoCContainer container)
        {
            base.ConfigureApplicationContainer(container);

            //plug in twitter api

            var consumerKey       = ConfigurationManager.AppSettings["ConsumerKey"];
            var consumerSecret    = ConfigurationManager.AppSettings["ConsumerSecret"];
            var accessToken       = ConfigurationManager.AppSettings["AccessToken"];
            var accessTokenSecret = ConfigurationManager.AppSettings["AccessTokenSecret"];

            var twitterApi =
                TweetSharpPublicClientAdapter.Create(consumerKey, consumerSecret, accessToken, accessTokenSecret)
                .GetAwaiter()
                .GetResult();

            // public twitter client singleton
            container.Register <ITwitterPublicClient>(twitterApi);

            // factory method for authed twitter client
            // instantiated on sign in then cached in-mem
            // for each user
            container.Register <ITwitterAuthenticatedClient>((_, __) => new TweetSharpAuthenticatedClientAdapter(consumerKey, consumerSecret));

            // user tracker singleton
            // maps session guids to IUserIdentity
            // retrieves authenticated twitter client for a given user
            var twitterUserTracker = new TwitterUserTracker();

            container.Register <ITwitterUserTracker>(twitterUserTracker);
            container.Register <IUserMapper>(twitterUserTracker);
        }
Пример #2
0
        protected override async Task <ITwitterPublicClient> GetClient()
        {
            var fixture =
                await
                TweetSharpPublicClientAdapter.Create(consumerKey, consumerSecret, accessToken, accessTokenSecret)
                .ConfigureAwait(false);

            return(fixture);
        }