public GameHub() { ObjectPersistence = new DefaultObjectStoreProvider(); SharedCache = new DefaultSharedCacheProvider(); RealTimeMessaging = new RealTimeMessagingProvider<GameHub>(); Synchronizer = new SynchController(SharedCache, ObjectPersistence, new DefaultRelationalStoreProvider()); }
public DatabaseGuidSharedCacheLookup(ISharedCache sharedCache) { if (sharedCache == null) { throw new ArgumentNullException("sharedCache"); } this.sharedCache = sharedCache; }
public AvatarProvider(ISharedCache sharedCache, IImageCache imageCache) { cache = sharedCache.LocalMachine; this.imageCache = imageCache; DefaultUserBitmapImage = CreateBitmapImage("pack://application:,,,/GitHub.App;component/Images/default_user_avatar.png"); DefaultOrgBitmapImage = CreateBitmapImage("pack://application:,,,/GitHub.App;component/Images/default_org_avatar.png"); }
protected AnchorMailboxSharedCacheLookup(ISharedCache sharedCache, RoutingItemType validItemType) { if (sharedCache == null) { throw new ArgumentNullException("sharedCache"); } this.sharedCache = sharedCache; this.validItemType = validItemType; }
public RepositoryHosts( IRepositoryHostFactory repositoryHostFactory, ISharedCache sharedCache, IConnectionManager connectionManager) { this.connectionManager = connectionManager; RepositoryHostFactory = repositoryHostFactory; disposables.Add(repositoryHostFactory); GitHubHost = DisconnectedRepositoryHost; EnterpriseHost = DisconnectedRepositoryHost; var initialCacheLoadObs = sharedCache.UserAccount.GetObject<Uri>(EnterpriseHostApiBaseUriCacheKey) .Catch<Uri, KeyNotFoundException>(_ => Observable.Return<Uri>(null)) .Catch<Uri, Exception>(ex => { log.Warn("Failed to get Enterprise host URI from cache.", ex); return Observable.Return<Uri>(null); }) .WhereNotNull() .Select(HostAddress.Create) .Where(x => connectionManager.Connections.Any(c => c.HostAddress.Equals(x))) .Select(repositoryHostFactory.Create) .Do(x => EnterpriseHost = x) .Do(disposables.Add) .SelectUnit(); var persistEntepriseHostObs = this.WhenAny(x => x.EnterpriseHost, x => x.Value) .Skip(1) // The first value will be null or something already in the db .SelectMany(enterpriseHost => { if (!enterpriseHost.IsLoggedIn) { return sharedCache.UserAccount .InvalidateObject<Uri>(EnterpriseHostApiBaseUriCacheKey) .Catch<Unit, Exception>(ex => { log.Warn("Failed to invalidate enterprise host uri", ex); return Observable.Return(Unit.Default); }); } return sharedCache.UserAccount .InsertObject(EnterpriseHostApiBaseUriCacheKey, enterpriseHost.Address.ApiUri) .Catch<Unit, Exception>(ex => { log.Warn("Failed to persist enterprise host uri", ex); return Observable.Return(Unit.Default); }); }); isLoggedInToAnyHost = this.WhenAny( x => x.GitHubHost.IsLoggedIn, x => x.EnterpriseHost.IsLoggedIn, (githubLoggedIn, enterpriseLoggedIn) => githubLoggedIn.Value || enterpriseLoggedIn.Value) .ToProperty(this, x => x.IsLoggedInToAnyHost); // This part is strictly to support having the IConnectionManager request that a connection // be logged in. It doesn't know about hosts or load anything reactive, so it gets // informed of logins by an observable returned by the event connectionManager.DoLogin += RunLoginHandler; // monitor the list of connections so we can log out hosts when connections are removed disposables.Add( connectionManager.Connections.CreateDerivedCollection(x => x) .ItemsRemoved .Select(x => { var host = LookupHost(x.HostAddress); if (host.Address != x.HostAddress) { host = RepositoryHostFactory.Create(x.HostAddress); } return host; }) .Select(h => LogOut(h)) .Merge().ToList().Select(_ => Unit.Default).Subscribe()); // Wait until we've loaded (or failed to load) an enterprise uri from the db and then // start tracking changes to the EnterpriseHost property and persist every change to the db disposables.Add(Observable.Concat(initialCacheLoadObs, persistEntepriseHostObs).Subscribe()); }
public GitHubCredentialProvider(ISharedCache sharedCache) { Guard.ArgumentNotNull(sharedCache, nameof(sharedCache)); secureCache = sharedCache.Secure; }
public LoginCache(ISharedCache cache) { this.cache = cache; }
public MailboxGuidSharedCacheLookup(ISharedCache sharedCache) : base(sharedCache, RoutingItemType.MailboxGuid) { }
public RepositoryHosts( IRepositoryHostFactory repositoryHostFactory, ISharedCache sharedCache, IConnectionManager connectionManager) { this.connectionManager = connectionManager; RepositoryHostFactory = repositoryHostFactory; GitHubHost = DisconnectedRepositoryHost; EnterpriseHost = DisconnectedRepositoryHost; var initialCacheLoadObs = sharedCache.UserAccount.GetObject <Uri>(EnterpriseHostApiBaseUriCacheKey) .Catch <Uri, KeyNotFoundException>(_ => Observable.Return <Uri>(null)) .Catch <Uri, Exception>(ex => { log.Warn("Failed to get Enterprise host URI from cache.", ex); return(Observable.Return <Uri>(null)); }) .WhereNotNull() .Select(HostAddress.Create) .Where(x => connectionManager.Connections.Any(c => c.HostAddress.Equals(x))) .Select(repositoryHostFactory.Create) .Do(x => EnterpriseHost = x) .Do(disposables.Add) .SelectUnit(); var persistEntepriseHostObs = this.WhenAny(x => x.EnterpriseHost, x => x.Value) .Skip(1) // The first value will be null or something already in the db .SelectMany(enterpriseHost => { if (!enterpriseHost.IsLoggedIn) { return(sharedCache.UserAccount .InvalidateObject <Uri>(EnterpriseHostApiBaseUriCacheKey) .Catch <Unit, Exception>(ex => { log.Warn("Failed to invalidate enterprise host uri", ex); return Observable.Return(Unit.Default); })); } return(sharedCache.UserAccount .InsertObject(EnterpriseHostApiBaseUriCacheKey, enterpriseHost.Address.ApiUri) .Catch <Unit, Exception>(ex => { log.Warn("Failed to persist enterprise host uri", ex); return Observable.Return(Unit.Default); })); }); isLoggedInToAnyHost = this.WhenAny( x => x.GitHubHost.IsLoggedIn, x => x.EnterpriseHost.IsLoggedIn, (githubLoggedIn, enterpriseLoggedIn) => githubLoggedIn.Value || enterpriseLoggedIn.Value) .ToProperty(this, x => x.IsLoggedInToAnyHost); // This part is strictly to support having the IConnectionManager request that a connection // be logged in. It doesn't know about hosts or load anything reactive, so it gets // informed of logins by an observable returned by the event connectionManager.DoLogin += RunLoginHandler; // monitor the list of connections so we can log out hosts when connections are removed disposables.Add( connectionManager.Connections.CreateDerivedCollection(x => x) .ItemsRemoved .Select(x => { var host = LookupHost(x.HostAddress); if (host.Address != x.HostAddress) { host = RepositoryHostFactory.Create(x.HostAddress); } return(host); }) .Select(h => LogOut(h)) .Merge().ToList().Select(_ => Unit.Default).Subscribe()); // Wait until we've loaded (or failed to load) an enterprise uri from the db and then // start tracking changes to the EnterpriseHost property and persist every change to the db disposables.Add(Observable.Concat(initialCacheLoadObs, persistEntepriseHostObs).Subscribe()); }
public ExternalDirectoryObjectIdSharedCacheLookup(ISharedCache sharedCache) : base(sharedCache, RoutingItemType.ExternalDirectoryObjectId) { }
public GitHubCredentialProvider(ISharedCache sharedCache) { secureCache = sharedCache.Secure; }
public SharedCacheLookupFactory(ISharedCache mailboxCache, ISharedCache databaseCache) { this.databaseCache = databaseCache; this.mailboxCache = mailboxCache; }
public SynchController(ISharedCache cache, IObjectPersistence objectStore, IRelationalPersistence relationalStore) { RelationalStore = relationalStore; Cache = cache; ObjectStore = objectStore; }
public LiveIdMemberNameSharedCacheLookup(ISharedCache sharedCache) : base(sharedCache, RoutingItemType.LiveIdMemberName) { }
public ArchiveSmtpSharedCacheLookup(ISharedCache sharedCache) : base(sharedCache, RoutingItemType.ArchiveSmtp) { }
public SmtpSharedCacheLookup(ISharedCache sharedCache) : base(sharedCache, RoutingItemType.Smtp) { }