public NewGameViewModel(Identity identity, MainNavigationModel mainNavigation, NameNavigationModel nameNavigation) { _identity = identity; _mainNavigation = mainNavigation; _nameNavigation = nameNavigation; _depState = new Dependent(delegate { _state = _identity.User != null ? StateId.Challenge : _identity.Claims.Any(claim => !claim.Responses.Any()) ? StateId.PendingUserName : StateId.YourName; }); _depChallenge = new Dependent(delegate { _depState.OnGet(); _challenge = _state == StateId.Challenge ? new ChallengeViewModel(_identity.User, _mainNavigation) : null; }); _depYourName = new Dependent(delegate { _depState.OnGet(); _yourName = _state == StateId.YourName ? new YourNameViewModel(_identity, _nameNavigation) : null; }); _depPendingUserName = new Dependent(delegate { _depState.OnGet(); _pendingUserName = _state == StateId.PendingUserName ? new PendingUserNameViewModel(_identity.Claims.FirstOrDefault(claim => !claim.Responses.Any())) : null; }); }
public SynchronizationService() { IStorageStrategy storageStrategy = IsolatedStorageStorageStrategy.Load(); //IStorageStrategy storageStrategy = new MemoryStorageStrategy(); POXConfigurationProvider configurationProvider = new POXConfigurationProvider(); _community = new Community(storageStrategy) .AddAsynchronousCommunicationStrategy(new POXAsynchronousCommunicationStrategy(configurationProvider)) .Register<CorrespondenceModel>() .Subscribe(() => _identity) .Subscribe(() => _identity.Claims) .Subscribe(() => _identity.ApprovedUsers) .Subscribe(() => _identity.ApprovedUsers .SelectMany(user => user.ActivePlayers) .Select(player => player.Game) ) .Subscribe(() => _identity.ApprovedUsers .SelectMany(user => user.PendingGameRequests) ); _identity = _community.AddFact(new Identity(GetAnonymousUserId())); configurationProvider.Identity = _identity; // Synchronize whenever the user has something to send. _community.FactAdded += delegate { Synchronize(); }; // Synchronize periodically while waiting for a response to a claim. _synchronizeTimer.Interval = TimeSpan.FromSeconds(3.0); _synchronizeTimer.Tick += (sender, e) => { if (_identity.User != null) _synchronizeTimer.Stop(); else if (_identity.Claims.Any(claim => !claim.Responses.Any())) Synchronize(); }; _synchronizeTimer.Start(); // Synchronize when the network becomes available. System.Net.NetworkInformation.NetworkChange.NetworkAddressChanged += (sender, e) => { if (NetworkInterface.GetIsNetworkAvailable()) Synchronize(); }; // And synchronize on startup or resume. Synchronize(); }
public void Initialize() { MemoryCommunicationStrategy sharedCommunication = new MemoryCommunicationStrategy(); _serverCommunity = new Community(new MemoryStorageStrategy()) .AddCommunicationStrategy(sharedCommunication) .Register<CorrespondenceModel>() .Subscribe(() => _service); _clientCommunity = new Community(new MemoryStorageStrategy()) .AddCommunicationStrategy(sharedCommunication) .Register<CorrespondenceModel>() .Subscribe(() => _identity.Claims) .Subscribe(() => _identity); _otherClientCommunity = new Community(new MemoryStorageStrategy()) .AddCommunicationStrategy(sharedCommunication) .Register<CorrespondenceModel>() .Subscribe(() => _otherIdentity.Claims); _service = _serverCommunity.AddFact(new IdentityService()); _identity = _clientCommunity.AddFact(new Identity("liveid:12345")); _otherIdentity = _otherClientCommunity.AddFact(new Identity("liveid:12345")); }
public ViewModelLocator(Identity identity, IPresentationServices presentationServices, MainNavigationModel mainNavigationModel, NameNavigationModel nameNavigationModel) { _identity = identity; _presentationServices = presentationServices; _mainNavigationModel = mainNavigationModel; _nameNavigationModel = nameNavigationModel; _main = new MainViewModel(_presentationServices, _identity, _mainNavigationModel); _newGame = new NewGameViewModel(_identity, _mainNavigationModel, _nameNavigationModel); _depGame = new Dependent(delegate { if (_mainNavigationModel.SelectedPlayer != null) { _game = new RemoteGameViewModel(_mainNavigationModel.SelectedPlayer, _mainNavigationModel); } else if (_mainNavigationModel.SelectedGameRequest != null) { _game = new GameRequestViewModel(_mainNavigationModel.SelectedGameRequest, _mainNavigationModel); } else { LocalGame localGame = _identity.ActiveLocalGames.FirstOrDefault(); if (localGame != null) _game = new LocalGameViewModel(localGame, _mainNavigationModel); else _game = null; } }); _depChat = new Dependent(delegate { _chat = _mainNavigationModel.SelectedPlayer == null ? null : new ChatViewModel(_mainNavigationModel.SelectedPlayer, _mainNavigationModel); }); _settings = new SettingsViewModel(_identity); }
public SettingsViewModel(Identity identity) { _identity = identity; }
public MainViewModel(IPresentationServices presentationServices, Identity identity, MainNavigationModel mainNavigation) { _presentationServices = presentationServices; _identity = identity; _mainNavigation = mainNavigation; }
// Fields // Results // Business constructor public DisableToastNotification( Identity identity ) { _unique = Guid.NewGuid(); InitializeResults(); _identity = new PredecessorObj<Identity>(this, RoleIdentity, identity); }
// Business constructor public Claim( Identity identity ,User user ,IdentityService identityService ) { InitializeResults(); _identity = new PredecessorObj<Identity>(this, RoleIdentity, identity); _user = new PredecessorObj<User>(this, RoleUser, user); _identityService = new PredecessorObj<IdentityService>(this, RoleIdentityService, identityService); }
// Business constructor public LocalGame( Identity identity ) { _unique = Guid.NewGuid(); InitializeResults(); _identity = new PredecessorObj<Identity>(this, RoleIdentity, identity); }
public CorrespondenceFact CreateFact(FactMemento memento) { Identity newFact = new Identity(memento); // Create a memory stream from the memento data. using (MemoryStream data = new MemoryStream(memento.Data)) { using (BinaryReader output = new BinaryReader(data)) { newFact._uri = (string)_fieldSerializerByType[typeof(string)].ReadData(output); } } return newFact; }
public YourNameViewModel(Identity identity, NameNavigationModel nameNavigation) { _identity = identity; _nameNavigation = nameNavigation; }