public UserManager(IMapper mapper, IUserDocumentDBProvider userDocumentDBprovider, ICognitiveFaceProvider cognitiveFaceProvider, ISocialMediaProvider socialMediaProvider) { _mapper = mapper; _cognitiveFaceProvider = cognitiveFaceProvider; _userDocumentDBprovider = userDocumentDBprovider; _socialMediaProvider = socialMediaProvider; }
private async Task <IUser> GetUser(string userName) { ApplicationUser currentUser = await _userManager.GetUserAsync(User); ISocialMediaProvider provider = await _twitter.UserToTwitter(currentUser); return(await provider.GetUserAsync(userName)); }
private async Task <ApplicationUser> GetTwitterUser( AuthenticationToken accessToken, AuthenticationToken accessTokenSecret) { ISocialMediaProvider twitter = GetTwitterProvider(accessToken, accessTokenSecret); IUser user = await twitter.GetIdentityAsync(); return(new ApplicationUser(user)); }
private async Task OperateOnPost(ISocialMediaProvider provider, IPost post, IUser currentUser) { bool hasUserOperatedOnPost = _validator.HasUserOperatedOnPost(post.Id, currentUser.Id); if (hasUserOperatedOnPost) { return; } await provider.LikeAsync(post); _validator.UserOperatedOnPost(post.Id, currentUser.Id); }
private async Task CheckNewPosts( IUser watchedUser, ISocialMediaProvider provider, DateTime postsSince) { IUser currentUser = await provider.GetIdentityAsync(); var query = new PostsSearchQuery(watchedUser) { Since = postsSince }; await foreach (IPost post in provider.FindPostsAsync(query)) { await OperateOnPost(provider, post, currentUser); } }
static void Main(string[] args) { try { UnityContainer container = new UnityContainer(); container.RegisterType <ILog, LogConsole>(); container.RegisterType <IRawDataQueue, RdqMemoryThreadSafe>(); container.RegisterType <ISocialMediaProvider, SmpTwitterSample>(); container.RegisterType <IDataStore, DsMemoryThreadSafe>(); container.RegisterType <IAnalyzer, AnalyzerLocal>(); container.RegisterType <IReporter, ReporterConsole>(); IRawDataQueue rdq = container.Resolve <IRawDataQueue>(); ISocialMediaProvider smp = container.Resolve <ISocialMediaProvider>(); IDataStore ds = container.Resolve <IDataStore>(); IAnalyzer analyzer = container.Resolve <IAnalyzer>(); IReporter reporter = container.Resolve <IReporter>(); //Set up a cancellation token to end the collection when appropriate using (CancellationTokenSource cancellationTokenSource = new CancellationTokenSource()) { CancellationToken cancel = cancellationTokenSource.Token; smp.Retrieve(rdq, cancel); analyzer.Analyze(rdq, ds, cancel); reporter.Send(ds, cancel); Console.WriteLine("Press 'Enter' to stop."); Console.ReadLine(); cancellationTokenSource.Cancel(); } Console.WriteLine("Cancellation request recieved. Press 'Enter' to exit program."); Console.ReadLine(); } catch (Exception ex) { Console.WriteLine("An exception occurred. See details below. Press 'Enter' to close program.\n{0}", ex.Message); Console.ReadLine(); } }
private Task Operation(ISocialMediaProvider provider) { OperationCounter++; return(Task.Delay(_delay)); }