/// <summary> /// Compares two instances of this object. /// </summary> /// <param name="RFIDIdentification">An RFID identification object to compare with.</param> public Int32 CompareTo(RFIDIdentification RFIDIdentification) { if ((Object)RFIDIdentification == null) { throw new ArgumentNullException(nameof(RFIDIdentification), "The given RFID identification must not be null!"); } var result = UID.CompareTo(RFIDIdentification.UID); if (result == 0) { result = RFIDType.CompareTo(RFIDIdentification.RFIDType); } if (result == 0) { result = EVCOId.HasValue && RFIDIdentification.EVCOId.HasValue ? EVCOId.Value.CompareTo(RFIDIdentification.EVCOId.Value) : 0; } if (result == 0) { result = String.Compare(PrintedNumber, RFIDIdentification.PrintedNumber, StringComparison.OrdinalIgnoreCase); } if (result == 0) { result = ExpiryDate.HasValue && RFIDIdentification.ExpiryDate.HasValue ? ExpiryDate.Value.CompareTo(RFIDIdentification.ExpiryDate.Value) : 0; } return(result); }
/// <summary> /// Return a JSON representation of this object. /// </summary> /// <param name="CustomRFIDIdentificationSerializer">A delegate to serialize custom RFID identification JSON objects.</param> public JObject ToJSON(CustomJObjectSerializerDelegate <RFIDIdentification> CustomRFIDIdentificationSerializer = null) { var JSON = JSONObject.Create( new JProperty("UID", UID.ToString()), new JProperty("RFID", RFIDType.AsString()), EVCOId.HasValue ? new JProperty("EvcoID", EVCOId.Value.ToString()) : null, PrintedNumber.IsNeitherNullNorEmpty() ? new JProperty("PrintedNumber", PrintedNumber) : null, ExpiryDate.HasValue ? new JProperty("ExpiryDate", ExpiryDate.Value.ToIso8601()) : null, CustomData?.HasValues == true ? new JProperty("CustomData", CustomData) : null ); return(CustomRFIDIdentificationSerializer != null ? CustomRFIDIdentificationSerializer(this, JSON) : JSON); }
/// <summary> /// Get the hashcode of this object. /// </summary> public override Int32 GetHashCode() { unchecked { return(EVCOId.GetHashCode() * 11 ^ RFIDType.GetHashCode() * 7 ^ (EVCOId.HasValue ? EVCOId.GetHashCode() * 5 : 0) ^ (PrintedNumber != null ? PrintedNumber.GetHashCode() * 3 : 0) ^ (EVCOId.HasValue ? EVCOId.GetHashCode() : 0)); } }
/// <summary> /// Compares two RFID identificationss for equality. /// </summary> /// <param name="RFIDIdentification">An RFID identification to compare with.</param> /// <returns>True if both match; False otherwise.</returns> public Boolean Equals(RFIDIdentification RFIDIdentification) { if ((Object)RFIDIdentification == null) { return(false); } return(UID.Equals(RFIDIdentification.UID) && RFIDType.Equals(RFIDIdentification.RFIDType) && ((!EVCOId.HasValue && !RFIDIdentification.EVCOId.HasValue) || (EVCOId.HasValue && RFIDIdentification.EVCOId.HasValue && EVCOId.Value.Equals(RFIDIdentification.EVCOId.Value))) && ((PrintedNumber == null && RFIDIdentification.PrintedNumber == null) || (PrintedNumber != null && RFIDIdentification.PrintedNumber != null && String.Compare(PrintedNumber, RFIDIdentification.PrintedNumber, StringComparison.OrdinalIgnoreCase) != 0)) && ((!ExpiryDate.HasValue && !RFIDIdentification.ExpiryDate.HasValue) || (ExpiryDate.HasValue && RFIDIdentification.ExpiryDate.HasValue && ExpiryDate.Value.Equals(RFIDIdentification.ExpiryDate.Value)))); }
/// <summary> /// Return a XML representation of this object. /// </summary> /// <param name="XName">The XML name to use.</param> public XElement ToXML(XName XName = null) => new XElement(XName ?? OICPNS.CommonTypes + "RFIDIdentification", new XElement(OICPNS.CommonTypes + "UID", UID.ToString()), EVCOId.HasValue ? new XElement(OICPNS.CommonTypes + "EvcoID", EVCOId.ToString()) : null, new XElement(OICPNS.CommonTypes + "RFIDType", RFIDType.ToString()), PrintedNumber.IsNeitherNullNorEmpty() ? new XElement(OICPNS.CommonTypes + "PrintedNumber", PrintedNumber) : null, ExpiryDate.HasValue ? new XElement(OICPNS.CommonTypes + "ExpiryDate", ExpiryDate.ToString()) : null );