public async Task <IModelService> CreateAsync(IConnection connection) { ModelService result; await cacheLock.WaitAsync(); try { if (!cache.TryGetValue(connection, out result)) { result = new ModelService( await apiClientFactory.Create(connection.HostAddress), await hostCacheFactory.Create(connection.HostAddress), avatarProvider); result.InsertUser(AccountCacheItem.Create(connection.User)); cache.Add(connection, result); } } finally { cacheLock.Release(); } return(result); }
public RepositoryCacheItem(Repository apiRepository) { Name = apiRepository.Name; Owner = AccountCacheItem.Create(apiRepository.Owner); CloneUrl = apiRepository.CloneUrl; Private = apiRepository.Private; Fork = apiRepository.Fork; }
public RepositoryCacheItem(Repository apiRepository) { Id = apiRepository.Id; Name = apiRepository.Name; Owner = AccountCacheItem.Create(apiRepository.Owner); CloneUrl = apiRepository.CloneUrl; Private = apiRepository.Private; Fork = apiRepository.Fork; Key = string.Format(CultureInfo.InvariantCulture, "{0}/{1}", Owner.Login, Name); CreatedAt = apiRepository.CreatedAt; UpdatedAt = apiRepository.UpdatedAt; Timestamp = apiRepository.UpdatedAt; }