public void KeyHendlerA() { if (KeyA != null) { KeyA.Invoke(); } }
/// <summary> /// Depending on the command, serialize the needed data /// Authentication will serialize the command, the concerned key and /// the serial number /// Reading data will just serialize the command /// Writing data will serialize the data as well /// </summary> /// <returns>The serialized bits</returns> private byte[] Serialize() { byte[] ser = null; switch (Command) { case MifareCardCommand.AuthenticationA: ser = new byte[2 + KeyA.Length + SerialNumber.Length]; ser[0] = (byte)Command; ser[1] = BlockNumber; if (KeyA.Length > 0) { KeyA.CopyTo(ser, 2); } if (SerialNumber.Length > 0) { SerialNumber.CopyTo(ser, 2 + KeyA.Length); } return(ser); case MifareCardCommand.AuthenticationB: ser = new byte[2 + KeyB.Length + SerialNumber.Length]; ser[0] = (byte)Command; ser[1] = BlockNumber; if (KeyB.Length > 0) { KeyB.CopyTo(ser, 2); } if (SerialNumber.Length > 0) { SerialNumber.CopyTo(ser, 2 + KeyB.Length); } return(ser); case MifareCardCommand.Write16Bytes: case MifareCardCommand.Write4Bytes: ser = new byte[2 + Data.Length]; ser[0] = (byte)Command; ser[1] = BlockNumber; if (Data.Length > 0) { Data.CopyTo(ser, 2); } return(ser); case MifareCardCommand.Incrementation: case MifareCardCommand.Decrementation: case MifareCardCommand.Transfer: case MifareCardCommand.Restore: case MifareCardCommand.Read16Bytes: default: ser = new byte[2]; ser[0] = (byte)Command; ser[1] = BlockNumber; return(ser); } }
private void Action() { if (!service.WriteCommand(ServiceEvent.ChangeTrailers, KeyA.Concat(AccessBits).Concat(KeyB).Concat(Encoding.ASCII.GetBytes(new char[] { (char)SelectedKey })).ToArray())) { return; } if (service.WaitForEndOfOperation() && service.CurrentState == ProgrammerState.OperationSuccess && service.CurrentCard != null) { service.CurrentAccess = service.rfidFactory.CreateRfidAccess(KeyA, KeyB, AccessBits, SelectedKey); } }
public override bool Equals(AbstractEntity other) { if (other == null) { return(false); } if (!ObjectContext.GetObjectType(GetType()).Equals(ObjectContext.GetObjectType(other.GetType()))) { return(false); } DoubleKeyEntity <TKeyA, TKeyB> castedOther = (DoubleKeyEntity <TKeyA, TKeyB>)other; return(!castedOther.IsEmptyKey() && KeyA.Equals(castedOther.KeyA) && KeyB.Equals(castedOther.KeyB)); }
/// <summary> /// Returns a string representation of the TwoKeyValueTriple<TKeyA, TKeyB, TValue>, using the string representations of the key and value. /// </summary> /// <returns>A string representation of the TwoKeyValueTriple<TKeyA, TKeyB, TValue>, which includes the string representations of the key and value.</returns> public override string ToString() { StringBuilder s = new StringBuilder(); s.Append('['); if (KeyA != null) { s.Append(KeyA.ToString()); } s.Append(", "); if (KeyB != null) { s.Append(KeyB.ToString()); } s.Append(", "); if (Value != null) { s.Append(Value.ToString()); } s.Append(']'); return(s.ToString()); }
void HandleInput() { //TODO: Break into chunks of actions that can be performed at the same time, ie movmenet actions, attack actions, etc if (Input.GetKeyDown(KeyCode.W)) { KeyW.Execute(Character, KeyW); } if (Input.GetKeyDown(KeyCode.A)) { KeyA.Execute(Character, KeyA); } if (Input.GetKeyDown(KeyCode.S)) { KeyS.Execute(Character, KeyS); } if (Input.GetKeyDown(KeyCode.D)) { KeyD.Execute(Character, KeyD); } //TODO: Ensure the following cant be pressed at the same time as an action else if (Input.GetKeyDown(KeyCode.R)) { KeyR.Execute(Character, KeyR); } else if (Input.GetKeyDown(KeyCode.Z)) { KeyZ.Execute(Character, KeyZ); } else { //No keys pushed //new IdleCommand().Execute(); } /*else if (Input.GetKeyDown(KeyCode.B)) * { * KeyB.Execute(KeyB); * }*/ }
void HandleInput() { if (Input.GetKeyDown(KeyCode.W)) { KeyW.Execute(snakehead); } else if (Input.GetKeyDown(KeyCode.S)) { KeyS.Execute(snakehead); } else if (Input.GetKeyDown(KeyCode.A)) { KeyA.Execute(snakehead); } else if (Input.GetKeyDown(KeyCode.D)) { KeyD.Execute(snakehead); } else if (Input.GetKeyDown(KeyCode.Space)) { snakehead.GetComponent <Snake>().CreateSnakePart(); //Time.timeScale = 3; } }
public override int GetHashCode() { return(IsEmptyKey() ? 0 : KeyA.GetHashCode() ^ KeyB.GetHashCode() ^ KeyC.GetHashCode() ^ KeyD.GetHashCode()); }
/// <summary> /// Depending on the command, serialize the needed data /// Authentication will serialize the command, the concerned key and /// the serial number /// Reading data will just serialize the command /// Writing data will serialize the data as well /// </summary> /// <returns>The serialized bits</returns> private byte[] Serialize() { byte[]? ser = null; switch (Command) { case MifareCardCommand.AuthenticationA: if (KeyA is null || SerialNumber is null) { throw new Exception($"Card is not configured for {nameof(MifareCardCommand.AuthenticationA)}."); } ser = new byte[2 + KeyA.Length + SerialNumber.Length]; ser[0] = (byte)Command; ser[1] = BlockNumber; if (KeyA.Length > 0) { KeyA.CopyTo(ser, 2); } if (SerialNumber.Length > 0) { SerialNumber.CopyTo(ser, 2 + KeyA.Length); } return(ser); case MifareCardCommand.AuthenticationB: if (KeyB is null || SerialNumber is null) { throw new Exception($"Card is not configured for {nameof(MifareCardCommand.AuthenticationB)}."); } ser = new byte[2 + KeyB.Length + SerialNumber.Length]; ser[0] = (byte)Command; ser[1] = BlockNumber; if (KeyB.Length > 0) { KeyB.CopyTo(ser, 2); } if (SerialNumber.Length > 0) { SerialNumber.CopyTo(ser, 2 + KeyB.Length); } return(ser); case MifareCardCommand.Write16Bytes: case MifareCardCommand.Write4Bytes: if (Data is null) { throw new Exception($"Card is not configured for {nameof(MifareCardCommand.Write4Bytes)}."); } ser = new byte[2 + Data.Length]; ser[0] = (byte)Command; ser[1] = BlockNumber; if (Data.Length > 0) { Data.CopyTo(ser, 2); } return(ser); case MifareCardCommand.Incrementation: case MifareCardCommand.Decrementation: case MifareCardCommand.Transfer: case MifareCardCommand.Restore: case MifareCardCommand.Read16Bytes: default: ser = new byte[2]; ser[0] = (byte)Command; ser[1] = BlockNumber; return(ser); } }