public static async Task <TwitterUser> GetUserAsync(string screenName) { var user = await UserProxy.GetUserAsync(screenName).ConfigureAwait(false); if (user == null) { var acc = Setting.Accounts.GetRandomOne(); if (acc == null) { return(null); } user = await acc.ShowUserAsync(screenName).ConfigureAwait(false); UserProxy.StoreUser(user); } return(user); }
public static async Task <TwitterUser> GetUserAsync(long id) { var user = await UserProxy.GetUserAsync(id).ConfigureAwait(false); if (user == null) { var acc = Setting.Accounts.GetRelatedOne(id); if (acc == null) { return(null); } user = await acc.ShowUserAsync(id).ConfigureAwait(false); UserProxy.StoreUser(user); } return(user); }
public static async Task <TwitterUser> GetUserAsync(string screenName, bool ignoreCache = false) { var user = ignoreCache ? null : await UserProxy.GetUserAsync(screenName).ConfigureAwait(false); if (user == null) { var acc = Setting.Accounts.GetRandomOne(); if (acc == null) { return(null); } user = (await acc.CreateAccessor().ShowUserAsync(new UserParameter(screenName), CancellationToken.None) .ConfigureAwait(false)).Result; UserProxy.StoreUser(user); } return(user); }
public static async Task <TwitterUser> GetUserAsync(long id) { var user = await UserProxy.GetUserAsync(id).ConfigureAwait(false); if (user == null) { var acc = Setting.Accounts.GetRelatedOne(id); if (acc == null) { return(null); } user = (await acc.CreateAccessor().ShowUserAsync(new UserParameter(id), CancellationToken.None) .ConfigureAwait(false)).Result; UserProxy.StoreUser(user); } return(user); }
public static IObservable <TwitterUser> GetUser(string screenName) { return(UserProxy.GetUserAsync(screenName) .ToObservable() .Where(_ => _ != null) .ConcatIfEmpty( () => { var acc = Setting.Accounts.GetRandomOne(); if (acc == null) { return Observable.Empty <TwitterUser>(); } return acc.ShowUserAsync(screenName) .ToObservable() .Do(u => Task.Run(() => UserProxy.StoreUser(u))); })); }