public ModelAdapter(IModel model) { this.readOnlyPropertyAdapter = this.CreatePropertyAdapter( () => this.ReadOnlyProperty, () => model.SourceProperty.ToHexString(" ") ); }
static InterpretedAtrAdapter() { IPropertyAdapterFactory <InterpretedAtrAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <InterpretedAtrAdapter>(); InterpretedAtrAdapter.globalInterfaceBytesAdapter = PropertyFactory.Create( nameof(InterpretedAtrAdapter.GlobalInterfaceBytes), instance => new GlobalInterfaceBytesAdapter(instance.atr.GlobalInterfaceBytes) ); InterpretedAtrAdapter.protocolParametersAdapter = PropertyFactory.Create( nameof(InterpretedAtrAdapter.ProtocolParameters), instance => instance.atr.ProtocolParameters, (instance, parameter) => ProtocolParameterAdapterBase.GetObject(parameter) ); InterpretedAtrAdapter.historicalCharactersAdapter = PropertyFactory.Create( nameof(InterpretedAtrAdapter.HistoricalCharacters), instance => AtrHistoricalBytesAdapterBase.GetObject(instance.atr.HistoricalCharacters, instance) ); InterpretedAtrAdapter.possibleTypesToIndicateAdditionallyAdapter = PropertyFactory.Create( nameof(InterpretedAtrAdapter.PossibleTypesToIndicateAdditionally), instance => EnumerationAdapter <ProtocolType> .Items.Where( type => type != ProtocolType.RfuF && instance.atr.ProtocolParameters.Any(_ => _.ProtocolType == type) == false ) ); }
static TokenizedAtrAdapter() { IPropertyAdapterFactory <TokenizedAtrAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <TokenizedAtrAdapter>(); TokenizedAtrAdapter.preambleAdapter = PropertyFactory.Create( nameof(TokenizedAtrAdapter.Preamble), instance => new AtrPreambleTokenAdapter(instance.tokenizedAtr.Preamble) ); TokenizedAtrAdapter.interfaceByteGroupsAdapter = PropertyFactory.Create( nameof(TokenizedAtrAdapter.InterfaceBytesGroups), instance => instance.tokenizedAtr.InterfaceByteGroups, (instance, group) => new AtrInterfaceByteGroupTokenAdapter(group) ); TokenizedAtrAdapter.historicalCharactersAdapter = PropertyFactory.Create( nameof(TokenizedAtrAdapter.HistoricalCharacters), instance => new AtrHistoricalCharactersTokenAdapter(instance.tokenizedAtr.HistoricalCharacters) ); TokenizedAtrAdapter.checksumAdapter = PropertyFactory.Create( nameof(TokenizedAtrAdapter.Checksum), instance => new AtrChecksumTokenAdapter(instance.tokenizedAtr.AtrChecksum) ); TokenizedAtrAdapter.extraBytesAdapter = PropertyFactory.Create( nameof(TokenizedAtrAdapter.ExtraBytes), instance => new AtrExtraBytesAdapter(instance.tokenizedAtr.ExtraBytes) ); }
static AtrInterfaceByteGroupToken() { AtrInterfaceByteGroupToken.numberAdapter = ObservableObject.GetPropertyAdapterFactory <AtrInterfaceByteGroupToken>().Create( nameof(AtrInterfaceByteGroupToken.Number), instance => instance.owner.InterfaceByteGroups.TakeWhile(_ => _ != instance).Count() + 1 ); }
static ModelEnumerationItemNodeAdapter() { ObservableObject.IPropertyAdapterFactory <ModelEnumerationItemNodeAdapter> Factory = ObservableObject.GetPropertyAdapterFactory <ModelEnumerationItemNodeAdapter>(); ModelEnumerationItemNodeAdapter.internalValueAdapter = Factory.Create( nameof(ModelEnumerationItemNodeAdapter.InternalValue), instance => ModelNodeBaseAdapter.GetAdapter(instance, instance.enumerationItem.Value) ); ModelEnumerationItemNodeAdapter.modelAdapter = Factory.Create( nameof(ModelEnumerationItemNodeAdapter.Model), instance => instance.InternalValue.Model ); ModelEnumerationItemNodeAdapter.nameAdapter = Factory.Create( nameof(ModelEnumerationItemNodeAdapter.Name), instance => instance.enumerationItem.Name ); ModelEnumerationItemNodeAdapter.typenameAdapter = Factory.Create( nameof(ModelEnumerationItemNodeAdapter.Typename), instance => instance.InternalValue.Typename ); ModelEnumerationItemNodeAdapter.valueAdapter = Factory.Create( nameof(ModelEnumerationItemNodeAdapter.Value), instance => instance.InternalValue.Value ); ModelEnumerationItemNodeAdapter.hasValueAdapter = Factory.Create( nameof(ModelEnumerationItemNodeAdapter.HasValue), instance => instance.InternalValue.HasValue ); ModelEnumerationItemNodeAdapter.childrenAdapter = Factory.Create( nameof(ModelEnumerationItemNodeAdapter.Children), instance => instance.InternalValue.Children ); }
static T1ProtocolParameterAdapter() { IPropertyAdapterFactory <T1ProtocolParameterAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <T1ProtocolParameterAdapter>(); T1ProtocolParameterAdapter.informationFieldSizeAdapter = PropertyFactory.Create( nameof(T1ProtocolParameterAdapter.InformationFieldSize), instance => instance.protocolParameters.IfscValue, (instance, value) => instance.protocolParameters.Ifsc = value ); T1ProtocolParameterAdapter.informationFieldSizeIsDefaultAdapter = PropertyFactory.Create( nameof(T1ProtocolParameterAdapter.InformationFieldSizeIsDefault), instance => instance.protocolParameters.Ifsc.HasValue == false ); T1ProtocolParameterAdapter.characterWaitingTimeAdapter = PropertyFactory.Create( nameof(T1ProtocolParameterAdapter.CharacterWaitingTime), instance => instance.protocolParameters.CwiValue ); T1ProtocolParameterAdapter.blockWaitingTimeAdapter = PropertyFactory.Create( nameof(T1ProtocolParameterAdapter.BlockWaitingTime), instance => instance.protocolParameters.BwiValue ); T1ProtocolParameterAdapter.blockAndCharacterWaitingTimeIsDefaultAdapter = PropertyFactory.Create( nameof(T1ProtocolParameterAdapter.BlockAndCharacterWaitingTimeIsDefault), instance => instance.protocolParameters.Bwi.HasValue == false && instance.protocolParameters.Cwi.HasValue == false ); T1ProtocolParameterAdapter.redundancyCodeAdapter = PropertyFactory.Create( nameof(T1ProtocolParameterAdapter.RedundancyCode), instance => EnumerationAdapter <RedundancyCodeType> .GetInstanceFor(instance.protocolParameters.RedundancyCodeValue), (instance, value) => instance.protocolParameters.RedundancyCode = value ); T1ProtocolParameterAdapter.redundancyCodeIsDefaultAdapter = PropertyFactory.Create( nameof(T1ProtocolParameterAdapter.RedundancyCodeIsDefault), instance => instance.protocolParameters.RedundancyCode.HasValue == false ); }
static DataObjectPreIssuingDataAdapter() { ObservableObject.IPropertyAdapterFactory <DataObjectPreIssuingDataAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <DataObjectPreIssuingDataAdapter>(); DataObjectPreIssuingDataAdapter.preIssuingDataAdapter = PropertyFactory.Create( nameof(DataObjectPreIssuingDataAdapter.PreIssuingData), instance => instance.value.PreIssuingData.ToHexString(" ") ); }
static AtrTokenAdapterBase() { IPropertyAdapterFactory <AtrTokenAdapterBase> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <AtrTokenAdapterBase>(); AtrTokenAdapterBase.bytesAdapter = PropertyFactory.Create( nameof(AtrTokenAdapterBase.Bytes), instance => instance.atrToken != null ? instance.atrToken.Bytes.ToHexString(" ") : null ); }
static UnknownProtocolParameterAdapter() { IPropertyAdapterFactory <UnknownProtocolParameterAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <UnknownProtocolParameterAdapter>(); UnknownProtocolParameterAdapter.protocolTypeAdapter = PropertyFactory.Create( nameof(UnknownProtocolParameterAdapter.ProtocolType), instance => EnumerationAdapter <ProtocolType> .GetInstanceFor(instance.protocolParameters.ProtocolType) ); }
internal ProtocolParametersBase(Atr owner, ProtocolType protocolType, Func <AtrInterfaceByteGroupToken, bool> groupTypeSelection) : base(owner, groupTypeSelection, (InterfaceByteGroupType)protocolType) { this.ProtocolType = protocolType; this.isOnlyIndicatedProtocolAdapter = this.CreatePropertyAdapter( nameof(ProtocolParametersBase.IsOnlyIndicatedProtocol), () => this.Owner.ProtocolParameters.Count() == 1 ); }
static DataObjectStatusIndicatorAdapter() { ObservableObject.IPropertyAdapterFactory <DataObjectStatusIndicatorAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <DataObjectStatusIndicatorAdapter>(); DataObjectStatusIndicatorAdapter.includedInTlvAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.IncludedInTlv), instance => instance.value.IncludedInTlv ); DataObjectStatusIndicatorAdapter.lifeCycleAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.LifeCycle), instance => instance.value.LifeCycle != null ? instance.value.LifeCycle.Value.ToString("X2") : null, (instance, value) => Helper.SetAsHexByteValue(value, _ => instance.value.LifeCycle = _) ); DataObjectStatusIndicatorAdapter.isLifeCycleDefinedAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.IsLifeCycleDefined), instance => instance.value.LifeCycle != null ); DataObjectStatusIndicatorAdapter.canUndefineLifeCycleAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.CanUndefineLifeCycle), instance => instance.value.CanUndefineLifeCycle ); DataObjectStatusIndicatorAdapter.lifeCycleInformationAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.LifeCycleInformation), instance => EnumerationAdapter <KnownLifeCycle> .GetInstanceFor(instance.value.LifeCycleInformation), (instance, value) => instance.value.LifeCycleInformation = value ); DataObjectStatusIndicatorAdapter.statusWordIndicationAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.StatusWordIndication), instance => EnumerationAdapter <StatusWordIndication> .GetInstanceFor(instance.value.StatusWordIndication), (instance, value) => instance.value.StatusWordIndication = value ); DataObjectStatusIndicatorAdapter.statusWordAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.StatusWord), instance => instance.value.StatusWord != null ? instance.value.StatusWord.Value.ToString("X4") : null, (instance, value) => Helper.SetAsHexUShortValue(value, _ => instance.value.StatusWord = _) ); DataObjectStatusIndicatorAdapter.statusWordCodingAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.StatusWordCoding), instance => EnumerationAdapter <StatusWordCoding> .GetInstanceFor(instance.value.IncludedInTlv?Classes.ATR.StatusWordCoding.WithinTlvData : Classes.ATR.StatusWordCoding.FollowingTlvData) ); DataObjectStatusIndicatorAdapter.isStatusWordDefinedAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.IsStatusWordDefined), instance => instance.value.StatusWordIndication != null ); DataObjectStatusIndicatorAdapter.canUndefineStatusWordAdapter = PropertyFactory.Create( nameof(DataObjectStatusIndicatorAdapter.CanUndefineStatusWord), instance => instance.value.CanUndefineStatusWordIndication ); }
static AtrInterfaceByteGroupTokenAdapter() { ObservableObject.IPropertyAdapterFactory <AtrInterfaceByteGroupTokenAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <AtrInterfaceByteGroupTokenAdapter>(); AtrInterfaceByteGroupTokenAdapter.groupNumberAdatper = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.GroupNumber), instance => instance.atrInterfaceByteGroupToken.Number ); AtrInterfaceByteGroupTokenAdapter.typeAdatper = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.Type), instance => EnumerationAdapter <InterfaceByteGroupType> .GetInstanceFor(instance.atrInterfaceByteGroupToken.Type) ); AtrInterfaceByteGroupTokenAdapter.taAdapter = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.Ta), instance => instance.atrInterfaceByteGroupToken.Ta.HasValue ? instance.atrInterfaceByteGroupToken.Ta.Value.ToHexString() : null, (instance, value) => instance.atrInterfaceByteGroupToken.Ta = !string.IsNullOrEmpty(value)?byte.Parse(value.Substring(0, Math.Min(value.Length, 2)), NumberStyles.HexNumber):(byte?)null ); AtrInterfaceByteGroupTokenAdapter.tbAdapter = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.Tb), instance => instance.atrInterfaceByteGroupToken.Tb.HasValue ? instance.atrInterfaceByteGroupToken.Tb.Value.ToHexString() : null, (instance, value) => instance.atrInterfaceByteGroupToken.Tb = !string.IsNullOrEmpty(value) ? byte.Parse(value.Substring(0, Math.Min(value.Length, 2)), NumberStyles.HexNumber) : (byte?)null ); AtrInterfaceByteGroupTokenAdapter.tcAdapter = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.Tc), instance => instance.atrInterfaceByteGroupToken.Tc.HasValue ? instance.atrInterfaceByteGroupToken.Tc.Value.ToHexString() : null, (instance, value) => instance.atrInterfaceByteGroupToken.Tc = !string.IsNullOrEmpty(value) ? byte.Parse(value.Substring(0, Math.Min(value.Length, 2)), NumberStyles.HexNumber) : (byte?)null ); AtrInterfaceByteGroupTokenAdapter.nextGroupTypeAdapter = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.NextGroupType), instance => EnumerationAdapter <InterfaceByteGroupType> .GetInstanceFor(instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator != null?instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator.GroupType:(InterfaceByteGroupType?)null) ); AtrInterfaceByteGroupTokenAdapter.nextBytesTypeAdapter = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.NextBytes), instance => instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator != null?AtrTokenAdapterBase.ToString(instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator.TaExists, instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator.TbExists, instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator.TcExists, instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator.TdExists):"not set" ); AtrInterfaceByteGroupTokenAdapter.possibleTypesToChangeToAdapter = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.PossibleTypesToChangeTo), instance => ((InterfaceByteGroupType[])Enum.GetValues(typeof(InterfaceByteGroupType))) .Where(_ => _ != InterfaceByteGroupType.Global) //gloabl cannot be set; the first group automatically is global .Where(_ => instance.atrInterfaceByteGroupToken.NextGroup != null) //nothing cannot be set if no next group .Where(_ => _ != instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator.GroupType) //we can skip what is already set .OrderBy(_ => (int)_) //Sort by id .SkipWhile(value => value < instance.atrInterfaceByteGroupToken.Type) //Next Group cannot be less than this group. Same is OK .TakeWhile(value => instance.atrInterfaceByteGroupToken.NextGroup.NextInterfaceBytesIndicator == null || value <= instance.atrInterfaceByteGroupToken.NextGroup.NextInterfaceBytesIndicator.GroupType), //next group cannot be higher than next to next group. Same is OK (instance, item) => EnumerationAdapter <InterfaceByteGroupType> .GetInstanceFor(item) ); AtrInterfaceByteGroupTokenAdapter.possibleTypesToAddNextGroupAdapter = PropertyFactory.Create( nameof(AtrInterfaceByteGroupTokenAdapter.PossibleTypesToAddNextGroup), instance => ((InterfaceByteGroupType[])Enum.GetValues(typeof(InterfaceByteGroupType))) .Where(_ => _ != InterfaceByteGroupType.Global) //gloabl cannot be set; the first group automatically is global .OrderBy(_ => (int)_) //Sort by id .SkipWhile(value => value < instance.atrInterfaceByteGroupToken.Type) //Next Group cannot be less than this group. Same is OK .TakeWhile(value => instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator == null || value <= instance.atrInterfaceByteGroupToken.NextInterfaceBytesIndicator.GroupType), //next group cannot be higher than next to next group. Same is OK (instance, item) => EnumerationAdapter <InterfaceByteGroupType> .GetInstanceFor(item) ); }
static DataObjectInitialAccessDataAdapter() { ObservableObject.IPropertyAdapterFactory <DataObjectInitialAccessDataAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <DataObjectInitialAccessDataAdapter>(); DataObjectInitialAccessDataAdapter.initialAccessDataAdapter = PropertyFactory.Create( nameof(DataObjectInitialAccessDataAdapter.InitialAccessDataApdu), instance => instance.value.InitialAccessData.GetApdu().ToHexString(" ") ); DataObjectInitialAccessDataAdapter.isInitialAccessDataReadBinaryAdapter = PropertyFactory.Create( nameof(DataObjectInitialAccessDataAdapter.IsInitialAccessDataReadBinary), instance => instance.value.InitialAccessData is CompactTlvDataObjectInitialAccessData.ReadBinary ); DataObjectInitialAccessDataAdapter.isInitialAccessDataReadRecordAdapter = PropertyFactory.Create( nameof(DataObjectInitialAccessDataAdapter.IsInitialAccessDataReadRecord), instance => instance.value.InitialAccessData is CompactTlvDataObjectInitialAccessData.ReadRecord ); DataObjectInitialAccessDataAdapter.isInitialAccessDataCompleteApduAdapter = PropertyFactory.Create( nameof(DataObjectInitialAccessDataAdapter.IsInitialAccessDataCompleteApdu), instance => instance.value.InitialAccessData is CompactTlvDataObjectInitialAccessData.CustomApdu ); DataObjectInitialAccessDataAdapter.lengthToReadBinaryAdapter = PropertyFactory.Create( nameof(DataObjectInitialAccessDataAdapter.LengthToReadBinary), instance => instance.value.InitialAccessData is CompactTlvDataObjectInitialAccessData.ReadBinary ? ((CompactTlvDataObjectInitialAccessData.ReadBinary)instance.value.InitialAccessData).LengthToRead : (byte?)null ); DataObjectInitialAccessDataAdapter.lengthToReadRecordAdapter = PropertyFactory.Create( nameof(DataObjectInitialAccessDataAdapter.LengthToReadRecord), instance => instance.value.InitialAccessData is CompactTlvDataObjectInitialAccessData.ReadRecord ? ((CompactTlvDataObjectInitialAccessData.ReadRecord)instance.value.InitialAccessData).LengthToRead : (byte?)null ); DataObjectInitialAccessDataAdapter.transparentShortFileIdAdapter = PropertyFactory.Create( nameof(DataObjectInitialAccessDataAdapter.TransparentShortFileId), instance => instance.value.InitialAccessData is CompactTlvDataObjectInitialAccessData.ReadBinary ? ((CompactTlvDataObjectInitialAccessData.ReadBinary)instance.value.InitialAccessData).ShortFileId : (byte?)null ); DataObjectInitialAccessDataAdapter.recordShortFileIdAdapter = PropertyFactory.Create( nameof(DataObjectInitialAccessDataAdapter.RecordShortFileId), instance => instance.value.InitialAccessData is CompactTlvDataObjectInitialAccessData.ReadRecord ? ((CompactTlvDataObjectInitialAccessData.ReadRecord)instance.value.InitialAccessData).ShortFileId : (byte?)null ); DataObjectInitialAccessDataAdapter.isTransparentShortFileIdDefinedAdapter = PropertyFactory.Create( nameof(DataObjectInitialAccessDataAdapter.IsTransparentShortFileIdDefined), instance => instance.value.InitialAccessData is CompactTlvDataObjectInitialAccessData.ReadBinary ? ((CompactTlvDataObjectInitialAccessData.ReadBinary)instance.value.InitialAccessData).ShortFileId != null : false ); DataObjectInitialAccessDataAdapter.customApduAdapter = PropertyFactory.Create( nameof(DataObjectInitialAccessDataAdapter.CustomApdu), instance => ((CompactTlvDataObjectInitialAccessData.CustomApdu)instance.value.InitialAccessData).ApduBytes.ToHexString(" ") ); }
static DataObjectRfuAdapter() { ObservableObject.IPropertyAdapterFactory <DataObjectRfuAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <DataObjectRfuAdapter>(); DataObjectRfuAdapter.rfuValueAdapter = PropertyFactory.Create( nameof(DataObjectRfuAdapter.RfuValue), instance => instance.value.RfuValue.ToHexString(" ") ); DataObjectRfuAdapter.tagAdapter = PropertyFactory.Create( nameof(DataObjectRfuAdapter.Tag), instance => instance.value.Tag ); }
static DataObjectApplicationIdentifierAdapter() { ObservableObject.IPropertyAdapterFactory <DataObjectApplicationIdentifierAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <DataObjectApplicationIdentifierAdapter>(); DataObjectApplicationIdentifierAdapter.aidAdapter = PropertyFactory.Create( nameof(DataObjectApplicationIdentifierAdapter.Aid), instance => instance.value.Aid.ToHexString() ); DataObjectApplicationIdentifierAdapter.ridAdapter = PropertyFactory.Create( nameof(DataObjectApplicationIdentifierAdapter.Rid), instance => DataObjectApplicationIdentifierAdapter.GetRidInfo(instance.value.Aid) ); }
static ModelComplexNodeAdapter() { ObservableObject.IPropertyAdapterFactory <ModelComplexNodeAdapter> Factory = ObservableObject.GetPropertyAdapterFactory <ModelComplexNodeAdapter>(); ModelComplexNodeAdapter.typenameAdapter = Factory.Create( nameof(ModelComplexNodeAdapter.Typename), instance => instance.model.Type.Name ); ModelComplexNodeAdapter.childrenAdapter = Factory.Create( nameof(ModelComplexNodeAdapter.Children), instance => instance.model.Properties, (instance, value) => ModelNodeBaseAdapter.GetAdapter(instance, value) ); }
static ModelValueNodeAdapter() { IPropertyAdapterFactory <ModelValueNodeAdapter> Factory = ObservableObject.GetPropertyAdapterFactory <ModelValueNodeAdapter>(); ModelValueNodeAdapter.typenameAdapter = Factory.Create( nameof(ModelValueNodeAdapter.Typename), instance => instance.model.Type == null ? "<null>" : instance.model.Type.Name ); ModelValueNodeAdapter.valueAdapter = Factory.Create( nameof(ModelValueNodeAdapter.Value), instance => instance.model.Value ); }
static DataObjectBaseAdapter() { ObservableObject.IPropertyAdapterFactory <DataObjectBaseAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <DataObjectBaseAdapter>(); DataObjectBaseAdapter.dataAdapter = PropertyFactory.Create( nameof(DataObjectBaseAdapter.Data), instance => instance.value.Data.ToHexString(" ") ); DataObjectBaseAdapter.dataErrorAdapter = PropertyFactory.Create( nameof(DataObjectBaseAdapter.DataError), instance => instance.value.DataError ); }
static T0ProtocolParameterAdapter() { IPropertyAdapterFactory <T0ProtocolParameterAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <T0ProtocolParameterAdapter>(); T0ProtocolParameterAdapter.waitingTimeIntegerAdapter = PropertyFactory.Create( nameof(T0ProtocolParameterAdapter.WaitingTimeInteger), instance => instance.protocolParameters.WaitingTimeIntegerValue, // read value or default (instance, value) => instance.protocolParameters.WaitingTimeInteger = value // set fix value ); T0ProtocolParameterAdapter.waitingTimeIntegerIsDefaultAdapter = PropertyFactory.Create( nameof(T0ProtocolParameterAdapter.WaitingTimeIntegerIsDefault), instance => instance.protocolParameters.WaitingTimeInteger.HasValue == false ); }
public ModelInfo(Expression <Func <object> > rootObject, string name, bool nonClosable) { this.name = name; this.NonClosable = nonClosable; this.rootObjectAdapter = this.CreatePropertyAdapter( nameof(ModelInfo.RootObject), rootObject ); this.rootAdapter = this.CreatePropertyAdapter( nameof(ModelInfo.Root), () => ModelNodeBase.GetNode(this.RootObject) ); }
public AtrHistoricalBytesAdapterBase(AtrHistoricalCharactersBase historicalCharacters, InterpretedAtrAdapter interpretedAtr) { this.interpretedAtr = interpretedAtr; this.historicalCharactersAdapter = this.CreatePropertyAdapter( nameof(this.HistoricalCharacters), () => historicalCharacters.HistoricalCharacters.ToHexString(" ") ); this.historicalCharacterTypesAdapter = this.CreatePropertyAdapter( nameof(this.HistoricalCharacterTypes), () => AtrHistoricalBytesAdapterBase.GetHistoricalCharacterTypes(this.interpretedAtr.HistoricalCharacters) ); this.PropertyChanged += this.AtrHistoricalBytesAdapterBase_PropertyChanged; this.setHistoricalCharacterTypeCommand = new DelegateCommand <EnumerationAdapter <HistoricalCharacterTypes> >(this.SetHistoricalCharacterType); }
/// <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."); }
static ModelPropertyNodeAdapter() { IPropertyAdapterFactory <ModelPropertyNodeAdapter> Factory = ObservableObject.GetPropertyAdapterFactory <ModelPropertyNodeAdapter>(); ModelPropertyNodeAdapter.internalValueAdapter = Factory.Create( nameof(ModelPropertyNodeAdapter.InternalValue), instance => ModelNodeBaseAdapter.GetAdapter(instance, instance.propertyNode.Value) ); ModelPropertyNodeAdapter.modelAdapter = Factory.Create( nameof(ModelPropertyNodeAdapter.Model), instance => instance.InternalValue.Model ); ModelPropertyNodeAdapter.nameAdapter = Factory.Create( nameof(ModelPropertyNodeAdapter.Name), instance => instance.propertyNode.Name ); ModelPropertyNodeAdapter.typenameAdapter = Factory.Create( nameof(ModelPropertyNodeAdapter.Typename), instance => instance.InternalValue.Typename ); ModelPropertyNodeAdapter.valueAdapter = Factory.Create( nameof(ModelPropertyNodeAdapter.Value), instance => instance.InternalValue.Value ); ModelPropertyNodeAdapter.hasValueAdapter = Factory.Create( nameof(ModelPropertyNodeAdapter.HasValue), instance => instance.InternalValue.HasValue ); ModelPropertyNodeAdapter.supportsValidationAdapter = Factory.Create( nameof(ModelPropertyNodeAdapter.SupportsValidation), instance => instance.propertyNode.SupportsValidation ); ModelPropertyNodeAdapter.validationSeverityAdapter = Factory.Create( nameof(ModelPropertyNodeAdapter.ValidationSeverity), instance => instance.propertyNode.ValidationSeverity ); ModelPropertyNodeAdapter.validationResultsAdapter = Factory.Create( nameof(ModelPropertyNodeAdapter.ValidationResults), instance => instance.propertyNode.ValidationResults, (instance, message) => message ); ModelPropertyNodeAdapter.childrenAdapter = Factory.Create( nameof(ModelPropertyNodeAdapter.Children), instance => instance.InternalValue.Children ); }
static AtrPreambleTokenAdapter() { ObservableObject.IPropertyAdapterFactory <AtrPreambleTokenAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <AtrPreambleTokenAdapter>(); AtrPreambleTokenAdapter.codingConventionAdapter = PropertyFactory.Create( nameof(AtrPreambleTokenAdapter.CodingConvention), instance => AtrPreambleTokenAdapter.ToString(instance.preamble.CodingConvention) ); AtrPreambleTokenAdapter.numberOfHistoricalCharactersAdapter = PropertyFactory.Create( nameof(AtrPreambleTokenAdapter.NumberOfHistoricalCharacters), instance => instance.preamble.NumberOfHistoricalCharacters ); AtrPreambleTokenAdapter.nextBytesTypeAdapter = PropertyFactory.Create( nameof(AtrPreambleTokenAdapter.NextBytes), instance => instance.preamble.NextInterfaceBytesIndicator != null ? AtrTokenAdapterBase.ToString(instance.preamble.NextInterfaceBytesIndicator.TaExists, instance.preamble.NextInterfaceBytesIndicator.TbExists, instance.preamble.NextInterfaceBytesIndicator.TcExists, instance.preamble.NextInterfaceBytesIndicator.TdExists) : "not set" ); }
static ModelInfoAdapter() { IPropertyAdapterFactory <ModelInfoAdapter> Factory = ObservableObject.GetPropertyAdapterFactory <ModelInfoAdapter>(); ModelInfoAdapter.typeNameAdapter = Factory.Create( nameof(ModelInfoAdapter.TypeName), instance => instance.Model.Root.Type != null ? instance.Model.Root.Type.Name : "null" ); ModelInfoAdapter.rootAdapter = Factory.Create( nameof(ModelInfoAdapter.Root), instance => ModelNodeBaseAdapter.GetAdapter(instance, instance.Model.Root) ); ModelInfoAdapter.nameAdapter = Factory.Create( nameof(ModelInfoAdapter.Name), instance => instance.Model.Name, (instance, value) => instance.Model.Name = value ); }
private PropertyNode(INotifyPropertyChanged owner, PropertyInfo propertyInfo) { this.owner = owner; this.propertyInfo = propertyInfo; this.owner.PropertyChanged += WeakDelegate.Connect <PropertyNode, INotifyPropertyChanged, PropertyChangedEventHandler, PropertyChangedEventArgs>( this, this.owner, (target, sender, eventargs) => target.OnPropertyChanged(sender, eventargs), (source, handler) => source.PropertyChanged -= handler); if (this.owner is INotifyDataErrorInfo) { ((INotifyDataErrorInfo)this.owner).ErrorsChanged += WeakDelegate.Connect <PropertyNode, INotifyDataErrorInfo, DataErrorsChangedEventArgs>( this, (INotifyDataErrorInfo)this.owner, (target, sender, eventargs) => target.OnErrorsChanged(eventargs), (source, handler) => source.ErrorsChanged -= handler); } this.UpdateNode(); this.validationSeverityAdapter = this.CreatePropertyAdapter( nameof(this.ValidationSeverity), () => this.ValidationResults.DefaultIfEmpty(new ValidationMessage(ValidationSeverity.None, "")).Max(message => message.Severity) ); }
public CardReaderAdapter(ICardReader cardReader) { this.CardReader = cardReader; this.nameAdapter = this.CreatePropertyAdapter( nameof(this.Name), () => cardReader.Name ); this.cardNameAdapter = this.CreatePropertyAdapter( nameof(this.CardName), () => cardReader.SmartCard != null? $"ATR: {cardReader.SmartCard.Atr.ToHexString()}" :"[no card inserted]" ); this.smartCardAdapter = this.CreatePropertyAdapter( nameof(this.SmartCard), () => cardReader.SmartCard ); }
public SmartCardSelectionModel() { this.cardReadersAdapter = this.CreatePropertyAdapter( nameof(this.CardReaders), () => this.SmartCardService != null ? this.SmartCardService.CardReaders : (IEnumerable <ICardReader>) new ICardReader[0], reader => new CardReaderAdapter(reader) ); ((INotifyCollectionChanged)this.CardReaders).CollectionChanged += this.CardReadersChanged; this.SelectedCardReader = this.CardReaders.FirstOrDefault(); this.allowCloseAdapter = this.CreatePropertyAdapter( nameof(this.AllowClose), () => this.SelectedCardReader != null && (this.AcceptEmptyCardReader || this.SelectedCardReader.SmartCard != null) ); this.smartCardMustBeInsertedAdapter = this.CreatePropertyAdapter( nameof(this.SmartCardMustBeInserted), () => this.AcceptEmptyCardReader == false && this.CardReaders.Any() && this.SelectedCardReader.SmartCard == null ); }
static DataObjectCountryCodeAdapter() { ObservableObject.IPropertyAdapterFactory <DataObjectCountryCodeAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <DataObjectCountryCodeAdapter>(); DataObjectCountryCodeAdapter.countryAdapter = PropertyFactory.Create( nameof(DataObjectCountryCodeAdapter.Country), instance => instance.value.Country, (instance, value) => instance.value.Country = value ); DataObjectCountryCodeAdapter.countryTextAdapter = PropertyFactory.Create( nameof(DataObjectCountryCodeAdapter.CountryText), instance => instance.value.Country.ToString() ); DataObjectCountryCodeAdapter.nationalDateAdapter = PropertyFactory.Create( nameof(DataObjectCountryCodeAdapter.NationalDate), instance => instance.value.NationalDate, (instance, value) => instance.value.NationalDate = value ); }
static AtrInvalidHistoricalBytesAdapter() { IPropertyAdapterFactory <AtrInvalidHistoricalBytesAdapter> PropertyFactory = ObservableObject.GetPropertyAdapterFactory <AtrInvalidHistoricalBytesAdapter>(); AtrInvalidHistoricalBytesAdapter.parseErrorAdapter = PropertyFactory.Create( nameof(AtrInvalidHistoricalBytesAdapter.ParseError), instance => instance.historicalCharacters.ParseError.Error ); AtrInvalidHistoricalBytesAdapter.preErrorDataAdapter = PropertyFactory.Create( nameof(AtrInvalidHistoricalBytesAdapter.PreErrorData), instance => instance.historicalCharacters.Bytes.Take(instance.historicalCharacters.ParseError.Index).ToHexString(" ") ); AtrInvalidHistoricalBytesAdapter.errorDataAdapter = PropertyFactory.Create( nameof(AtrInvalidHistoricalBytesAdapter.ErrorData), instance => instance.historicalCharacters.Bytes.Skip(instance.historicalCharacters.ParseError.Index).Take(1).ToHexString(" ") ); AtrInvalidHistoricalBytesAdapter.postErrorDataAdapter = PropertyFactory.Create( nameof(AtrInvalidHistoricalBytesAdapter.PostErrorData), instance => instance.historicalCharacters.Bytes.Skip(instance.historicalCharacters.ParseError.Index + 1).ToHexString(" ") ); }