using System; namespace GemCard { /// /// This class is used to update a set of parameters of an APDUCommand object /// public class APDUParam { byte bClass; byte bChannel; byte bP2; byte bP1; byte[] baData; short nLe; bool fUseP1; bool fUseP2; bool fChannel; bool fData; bool fClass; bool fLe; /// /// Resets the current instance, all flags are set to false /// public void Reset() { bClass = 0; bChannel = 0; bP2 = 0; bP1 = 0; baData = null; nLe = -1; fUseP1 = false; fUseP2 = false; fChannel = false; fData = false; fClass = false; fLe = false; } #region Constructors public APDUParam() { Reset(); } /// /// Copy constructor (used for cloning) /// /// public APDUParam(APDUParam param) { // Copy field if (param.baData != null) { param.baData.CopyTo(baData, 0); } this.bClass = param.bClass; this.bChannel = param.bChannel; this.bP1 = param.bP1; this.bP2 = param.bP2; this.nLe = param.nLe; // Copy flags field this.fChannel = param.fChannel; this.fClass = param.fClass; this.fData = param.fData; this.fLe = param.fLe; this.fUseP1 = param.fUseP1; this.fUseP2 = param.fUseP2; } public APDUParam(byte bClass, byte bP1, byte bP2, byte[] baData, short nLe) { this.Class = bClass; this.P1 = bP1; this.P2 = bP2; this.Data = baData; this.Le = (byte)nLe; } #endregion /// /// Clones the current APDUParam instance /// /// public APDUParam Clone() { return new APDUParam(this); } #region Properties public bool UseClass { get { return fClass; } } public bool UseChannel { get { return fChannel; } } public bool UseLe { get { return fLe; } } public bool UseData { get { return fData; } } public bool UseP1 { get { return fUseP1; } } public bool UseP2 { get { return fUseP2; } } public byte P1 { get { return bP1; } set { bP1 = value; fUseP1 = true; } } public byte P2 { get { return bP2; } set { bP2 = value; fUseP2 = true; } } public byte[] Data { get { return baData; } set { baData = value; fData = true; } } public byte Le { get { return (byte)nLe; } set { nLe = value; fLe = true; } } public byte Channel { get { return bChannel; } set { bChannel = value; fChannel = true; } } public byte Class { get { return bClass; } set { bClass = value; fClass = true; } } #endregion } }