public ICardReader ShowModal(ISmartCardService smartCardService, bool acceptEmptyCardReader, string details)
 {
     this.model.SmartCardService      = smartCardService;
     this.model.AcceptEmptyCardReader = acceptEmptyCardReader;
     this.model.Details = details;
     this.view.ShowModal();
     return(this.model.SelectedCardReader.CardReader);
 }
Exemple #2
0
 public ICardReader SelectCardReader(ISmartCardService smartCardService, string details)
 {
     using (ComponentContainer ComponentContainer = new ComponentContainer(this.componentRepository))
     {
         ISmartCardSelection Selection = ComponentContainer.ResolveInstance <ISmartCardSelection>();
         return(Selection.ShowModal(smartCardService, true, details));
     }
 }
        /// <summary/>
        public ApduSenderModel(ISmartCardUiProvider smartCardUiProvider, ISmartCardService smartCardService, ICommonDialogProvider commonDialogProvider)
        {
            this.smartCardUiProvider  = smartCardUiProvider;
            this.smartCardService     = smartCardService;
            this.commonDialogProvider = commonDialogProvider;

            this.unavailableStateAdapter = this.CreatePropertyAdapter(
                nameof(ApduSenderModel.UnavailableState),
                () => this.CardReader == null ? UnavailableState.NoCardReaderSelected :
                this.CardReader.SmartCard == null ? UnavailableState.NoSmartCardInReader : UnavailableState.Available
                );

            this.isAvailableAdapter = this.CreatePropertyAdapter(
                nameof(ApduSenderModel.IsAvailable),
                () => this.UnavailableState == UnavailableState.Available
                );

            this.smartCardAtrAdapter = this.CreatePropertyAdapter(
                nameof(this.SmartCardAtr),
                () => this.CardReader != null?
                this.CardReader.SmartCard != null?
                this.CardReader.SmartCard.Atr.ToHexString(" "):"":""
                );

            this.isSmartCardConnectedAdapter = this.CreatePropertyAdapter(
                nameof(ApduSenderModel.IsSmartCardConnected),
                () => this.CardReader != null ?
                this.CardReader.SmartCard != null ?
                this.CardReader.SmartCard.IsConnected :false : false
                );

            this.hasLastCommandAdapter = this.CreatePropertyAdapter(
                nameof(ApduSenderModel.HasLastCommand),
                () => this.LastCommand != null
                );

            this.SelectReaderCommand = new DelegateCommand(this.SelectReader);
            this.SendApduCommand     = new DelegateCommand(this.SendCommand, () => this.Command.CanConvertToByteArray() && this.Command.ToByteArray().Length >= 5 && this.IsSmartCardConnected);
            this.ConnectT0Command    = new DelegateCommand(() => this.Connect(Protocol.T0), () => this.IsSmartCardConnected == false);
            this.ConnectT1Command    = new DelegateCommand(() => this.Connect(Protocol.T1), () => this.IsSmartCardConnected == false);
            this.DisconnectCommand   = new DelegateCommand(this.Disconnect, () => this.IsSmartCardConnected);

            this.AddValidationForProperty(() => this.Command)
            .AddValidation(value => string.IsNullOrEmpty(value) == false, value => new ValidationMessage(ValidationSeverity.Info, "Please enter an APDU command to send"))
            .AddValidation(value => string.IsNullOrEmpty(value) || value.CanConvertToByteArray(), value => "Command is not a valid hexadecimal string")
            .AddValidation(value => string.IsNullOrEmpty(value) || value.CanConvertToByteArray() == false || value.ToByteArray().Length >= 5, value => "Command must be min 5 bytes in length.");
        }
 public ICardReader SelectCardReader(ISmartCardService smartCardService, string details)
 {
     return(this.selectionProvider.SelectCardReader(smartCardService, details));
 }
 public ApduSenderModel(ISmartCardUiProvider smartCardUiProvider, WhileTrue.Modules.ModelInspector.IModelInspector modelInspector, ISmartCardService smartCardService, ICommonDialogProvider commonDialogProvider)
     : this(smartCardUiProvider, smartCardService, commonDialogProvider)
 {
     modelInspector.Inspect(this, "APDU Sender Model");
     this.smartCardService = smartCardService;
 }