Exemplo n.º 1
0
        protected override void InitializeCommands()
        {
            this.CreateRegistrationCommand = new PresenterCommand()
            {
                CanExecuteDelegate = code => PeerClassifier.Length > 0,
                ExecuteDelegate = code =>
                {
                    PeerName name = new PeerName(this.PeerClassifier,_peerNameType);

                    try
                    {
                        _service.CreateRegistration(name, 8080);
                    }
                    catch (PeerToPeerException ex)
                    {
                        ServiceLocator.Resolve<IMessageBoxService>().ShowError(ex.Message);
                    }
                    finally
                    {

                        this.PeerClassifier = string.Empty;
                    }
                }
            };

            this.SetSecureCommand = new PresenterCommand()
            {
                CanExecuteDelegate = secure => true,
                ExecuteDelegate = secure =>
                    {
                        _peerNameType = ((bool)secure) ? PeerNameType.Secured : PeerNameType.Unsecured;
                    }
            };

            this.LookupRegistrationCommand = new PresenterCommand
            {
                CanExecuteDelegate = code => PeerClassifier.Length>0,
                ExecuteDelegate = code =>
                    {
                        try
                        {
                            PeerName peer = new PeerName(PeerClassifier, _peerNameType);
                            LookupPresenter presenter = new LookupPresenter(peer,_service);
                            ServiceLocator.Resolve<IDialogService>().ShowDialog("LookUpRegistration", presenter);
                        }
                        catch (PeerToPeerException ex)
                        {
                            ServiceLocator.Resolve<IMessageBoxService>().ShowError(ex.Message);
                        }
                        finally
                        {
                            this.PeerClassifier = string.Empty;
                        }
                    }
            };
        }
Exemplo n.º 2
0
        protected override void InitializeCommands()
        {
            this.CreateRegistrationCommand = new PresenterCommand()
            {
                CanExecuteDelegate = code => PeerClassifier.Length > 0,
                ExecuteDelegate    = code =>
                {
                    PeerName name = new PeerName(this.PeerClassifier, _peerNameType);

                    try
                    {
                        _service.CreateRegistration(name, 8080);
                    }
                    catch (PeerToPeerException ex)
                    {
                        ServiceLocator.Resolve <IMessageBoxService>().ShowError(ex.Message);
                    }
                    finally
                    {
                        this.PeerClassifier = string.Empty;
                    }
                }
            };

            this.SetSecureCommand = new PresenterCommand()
            {
                CanExecuteDelegate = secure => true,
                ExecuteDelegate    = secure =>
                {
                    _peerNameType = ((bool)secure) ? PeerNameType.Secured : PeerNameType.Unsecured;
                }
            };

            this.LookupRegistrationCommand = new PresenterCommand
            {
                CanExecuteDelegate = code => PeerClassifier.Length > 0,
                ExecuteDelegate    = code =>
                {
                    try
                    {
                        PeerName        peer      = new PeerName(PeerClassifier, _peerNameType);
                        LookupPresenter presenter = new LookupPresenter(peer, _service);
                        ServiceLocator.Resolve <IDialogService>().ShowDialog("LookUpRegistration", presenter);
                    }
                    catch (PeerToPeerException ex)
                    {
                        ServiceLocator.Resolve <IMessageBoxService>().ShowError(ex.Message);
                    }
                    finally
                    {
                        this.PeerClassifier = string.Empty;
                    }
                }
            };
        }