/// <summary> /// Parse the given text representation of a GetChargeDetailRecords response. /// </summary> /// <param name="Request">The request leading to this response.</param> /// <param name="Text">The text to parse.</param> /// <param name="ResponseTimestamp">The timestamp of the response creation.</param> /// <param name="EventTrackingId">An optional event tracking identification for correlating this response with other events.</param> /// <param name="Runtime">The runtime of the request/response.</param> /// <param name="ProcessId">The optional Hubject process identification of the request.</param> /// <param name="HTTPResponse">The optional HTTP response.</param> /// <param name="CustomGetChargeDetailRecordsResponseParser">A delegate to parse custom GetChargeDetailRecords response JSON objects.</param> public static GetChargeDetailRecordsResponse Parse(GetChargeDetailRecordsRequest Request, String Text, DateTime ResponseTimestamp, EventTracking_Id EventTrackingId, TimeSpan Runtime, Process_Id?ProcessId = null, HTTPResponse HTTPResponse = null, CustomJObjectParserDelegate <GetChargeDetailRecordsResponse> CustomGetChargeDetailRecordsResponseParser = null) { if (TryParse(Request, Text, ResponseTimestamp, EventTrackingId, Runtime, out GetChargeDetailRecordsResponse getChargeDetailRecordsResponse, out String ErrorResponse, ProcessId, HTTPResponse, CustomGetChargeDetailRecordsResponseParser)) { return(getChargeDetailRecordsResponse); } throw new ArgumentException("The given text representation of a GetChargeDetailRecords response is invalid: " + ErrorResponse, nameof(Text)); }
/// <summary> /// Try to parse the given text representation of a PullEVSEStatus response. /// </summary> /// <param name="Request">The request leading to this response.</param> /// <param name="Text">The text to parse.</param> /// <param name="ResponseTimestamp">The timestamp of the response creation.</param> /// <param name="EventTrackingId">An optional event tracking identification for correlating this response with other events.</param> /// <param name="Runtime">The runtime of the request/response.</param> /// <param name="PullEVSEStatusResponse">The parsed PullEVSEStatus response.</param> /// <param name="ErrorResponse">An optional error response.</param> /// <param name="ProcessId">The optional Hubject process identification of the request.</param> /// <param name="HTTPResponse">The optional HTTP response.</param> /// <param name="CustomPullEVSEStatusResponseParser">A delegate to parse custom PullEVSEStatus response JSON objects.</param> public static Boolean TryParse(PullEVSEStatusRequest Request, String Text, DateTime ResponseTimestamp, EventTracking_Id EventTrackingId, TimeSpan Runtime, out PullEVSEStatusResponse PullEVSEStatusResponse, out String ErrorResponse, Process_Id?ProcessId = null, HTTPResponse HTTPResponse = null, CustomJObjectParserDelegate <PullEVSEStatusResponse> CustomPullEVSEStatusResponseParser = null) { try { return(TryParse(Request, JObject.Parse(Text), ResponseTimestamp, EventTrackingId, Runtime, out PullEVSEStatusResponse, out ErrorResponse, ProcessId, HTTPResponse, CustomPullEVSEStatusResponseParser)); } catch (Exception e) { PullEVSEStatusResponse = default; ErrorResponse = "The given text representation of a PullEVSEStatus response is invalid: " + e.Message; return(false); } }
/// <summary> /// Parse the given text representation of a PullEVSEStatus response. /// </summary> /// <param name="Request">The request leading to this response.</param> /// <param name="Text">The text to parse.</param> /// <param name="ResponseTimestamp">The timestamp of the response creation.</param> /// <param name="EventTrackingId">An optional event tracking identification for correlating this response with other events.</param> /// <param name="Runtime">The runtime of the request/response.</param> /// <param name="ProcessId">The optional Hubject process identification of the request.</param> /// <param name="HTTPResponse">The optional HTTP response.</param> /// <param name="CustomPullEVSEStatusResponseParser">A delegate to parse custom PullEVSEStatus response JSON objects.</param> public static PullEVSEStatusResponse Parse(PullEVSEStatusRequest Request, String Text, DateTime ResponseTimestamp, EventTracking_Id EventTrackingId, TimeSpan Runtime, Process_Id?ProcessId = null, HTTPResponse HTTPResponse = null, CustomJObjectParserDelegate <PullEVSEStatusResponse> CustomPullEVSEStatusResponseParser = null) { if (TryParse(Request, Text, ResponseTimestamp, EventTrackingId, Runtime, out PullEVSEStatusResponse pullEVSEStatusResponse, out String ErrorResponse, ProcessId, HTTPResponse, CustomPullEVSEStatusResponseParser)) { return(pullEVSEStatusResponse); } throw new ArgumentException("The given text representation of a PullEVSEStatus response is invalid: " + ErrorResponse, nameof(Text)); }
/// <summary> /// The request failed. /// </summary> /// <param name="Request">The request.</param> /// <param name="Result">The result.</param> /// <param name="ProcessId">The process identification of the result.</param> public static OICPResult <T> Failed(Object Request, T Result, Process_Id?ProcessId = null) => new OICPResult <T>(Request, Result, false, null, ProcessId);
/// <summary> /// The request succeed. /// </summary> /// <param name="Request">The request.</param> /// <param name="Result">The result.</param> /// <param name="ProcessId">The process identification of the result.</param> public static OICPResult <T> Success(Object Request, T Result, Process_Id?ProcessId = null) => new OICPResult <T>(Request, Result, true, null, ProcessId);
/// <summary> /// Create a new generic OICP result. /// </summary> /// <param name="Request">The request.</param> /// <param name="Response">The result.</param> /// <param name="WasSuccessful">The request was successful.</param> /// <param name="ValidationErrors">Possible request data validation errors.</param> /// <param name="ProcessId">The process identification of the result.</param> private OICPResult(Object Request, T Response, Boolean WasSuccessful, ValidationErrorList ValidationErrors, Process_Id?ProcessId) { this.Request = Request; this.Response = Response; this.WasSuccessful = WasSuccessful; this.ValidationErrors = ValidationErrors; this.ProcessId = ProcessId; }
/// <summary> /// Create a new generic response. /// </summary> /// <param name="Request">The request leading to this result.</param> /// <param name="ResponseTimestamp">The timestamp of the response creation.</param> /// <param name="EventTrackingId">An optional event tracking identification for correlating this response with other events.</param> /// <param name="Runtime">The runtime of the request/response.</param> /// <param name="HTTPResponse">The optional HTTP response.</param> /// <param name="ProcessId">The optional Hubject process identification of the request.</param> /// <param name="CustomData">Optional customer-specific data of the response.</param> protected Builder(TRequest Request = null, DateTime?ResponseTimestamp = null, EventTracking_Id EventTrackingId = null, TimeSpan?Runtime = null, HTTPResponse HTTPResponse = null, Process_Id?ProcessId = null, JObject CustomData = null) { this.Request = Request; this.ResponseTimestamp = ResponseTimestamp; this.EventTrackingId = EventTrackingId; this.Runtime = Runtime; this.HTTPResponse = HTTPResponse; this.ProcessId = ProcessId; this.CustomData = CustomData; }
/// <summary> /// Create a new generic response. /// </summary> /// <param name="Request">The request leading to this result.</param> /// <param name="ResponseTimestamp">The timestamp of the response creation.</param> /// <param name="EventTrackingId">An optional event tracking identification for correlating this response with other events.</param> /// <param name="Runtime">The runtime of the request/response.</param> /// <param name="HTTPResponse">The optional HTTP response.</param> /// <param name="ProcessId">The optional Hubject process identification of the request.</param> /// <param name="CustomData">Optional customer specific data, e.g. in combination with custom parsers and serializers.</param> protected AResponse(TRequest Request, DateTime ResponseTimestamp, EventTracking_Id EventTrackingId, TimeSpan Runtime, HTTPResponse HTTPResponse = null, Process_Id?ProcessId = null, JObject CustomData = null) { this.Request = Request ?? throw new ArgumentNullException(nameof(Request), "The given request must not be null!"); this.ResponseTimestamp = ResponseTimestamp; this.EventTrackingId = EventTrackingId; this.Runtime = Runtime; this.HTTPResponse = HTTPResponse; this.ProcessId = ProcessId; this.CustomData = CustomData; }
/// <summary> /// Create a new PullEVSEData response. /// </summary> /// <param name="Request">A PullEVSEData request.</param> /// <param name="ResponseTimestamp">The timestamp of the response creation.</param> /// <param name="EventTrackingId">An optional event tracking identification for correlating this response with other events.</param> /// <param name="Runtime">The runtime of the request/response.</param> /// <param name="EVSEDataRecords">An enumeration of EVSE data records.</param> /// <param name="StatusCode">An optional status code of this response.</param> /// <param name="ProcessId">The optional Hubject process identification of the request.</param> /// <param name="HTTPResponse">The optional HTTP response.</param> /// <param name="CustomData">Optional customer specific data, e.g. in combination with custom parsers and serializers.</param> /// <param name="Warnings">Optional warnings.</param> public PullEVSEDataResponse(PullEVSEDataRequest Request, DateTime ResponseTimestamp, EventTracking_Id EventTrackingId, TimeSpan Runtime, IEnumerable <EVSEDataRecord> EVSEDataRecords, UInt64?Number = null, UInt64?Size = null, UInt64?TotalElements = null, Boolean?LastPage = null, Boolean?FirstPage = null, UInt64?TotalPages = null, UInt64?NumberOfElements = null, StatusCode StatusCode = null, Process_Id?ProcessId = null, HTTPResponse HTTPResponse = null, JObject CustomData = null, IEnumerable <Warning> Warnings = null) : base(Request, ResponseTimestamp, EventTrackingId, Runtime, HTTPResponse, ProcessId, CustomData) { this.EVSEDataRecords = EVSEDataRecords ?? throw new ArgumentNullException(nameof(EVSEDataRecords), "The given enumeration of EVSE data records must not be null!"); this.Number = Number; this.Size = Size; this.TotalElements = TotalElements; this.LastPage = LastPage; this.FirstPage = FirstPage; this.TotalPages = TotalPages; this.NumberOfElements = NumberOfElements; this.StatusCode = StatusCode; this.Warnings = Warnings ?? new Warning[0]; }
/// <summary> /// Create a new GetChargeDetailRecords response. /// </summary> /// <param name="Request">A GetChargeDetailRecords request.</param> /// <param name="ResponseTimestamp">The timestamp of the response creation.</param> /// <param name="EventTrackingId">An optional event tracking identification for correlating this response with other events.</param> /// <param name="Runtime">The runtime of the request/response.</param> /// /// <param name="ChargeDetailRecords">An enumeration of charge detail records.</param> /// /// <param name="StatusCode">An optional status code of this response.</param> /// <param name="ProcessId">The optional Hubject process identification of the request.</param> /// <param name="HTTPResponse">The optional HTTP response.</param> /// /// <param name="CustomData">Optional customer specific data, e.g. in combination with custom parsers and serializers.</param> public GetChargeDetailRecordsResponse(GetChargeDetailRecordsRequest Request, DateTime ResponseTimestamp, EventTracking_Id EventTrackingId, TimeSpan Runtime, IEnumerable <ChargeDetailRecord> ChargeDetailRecords, HTTPResponse HTTPResponse = null, Process_Id?ProcessId = null, StatusCode StatusCode = null, Boolean?First = null, Boolean?Last = null, UInt32?Number = null, UInt32?NumberOfElements = null, UInt32?Size = null, UInt32?TotalElements = null, UInt32?TotalPages = null, JObject CustomData = null) : base(Request, ResponseTimestamp, EventTrackingId, Runtime, HTTPResponse, ProcessId, StatusCode, First, Last, Number, NumberOfElements, Size, TotalElements, TotalPages, CustomData) { this.ChargeDetailRecords = ChargeDetailRecords ?? throw new ArgumentNullException(nameof(ChargeDetailRecords), "The given enumeration of charge detail records must not be null!"); }
/// <summary> /// Create a new PullEVSEStatusById response. /// </summary> /// <param name="Request">A PullEVSEStatusById request.</param> /// <param name="ResponseTimestamp">The timestamp of the response creation.</param> /// <param name="EventTrackingId">An optional event tracking identification for correlating this response with other events.</param> /// <param name="Runtime">The runtime of the request/response.</param> /// <param name="EVSEStatusRecords">An enumeration of EVSE status records.</param> /// <param name="StatusCode">An optional status code of this response.</param> /// <param name="ProcessId">The optional Hubject process identification of the request.</param> /// <param name="HTTPResponse">The optional HTTP response.</param> /// <param name="CustomData">Optional customer specific data, e.g. in combination with custom parsers and serializers.</param> public PullEVSEStatusByIdResponse(PullEVSEStatusByIdRequest Request, DateTime ResponseTimestamp, EventTracking_Id EventTrackingId, TimeSpan Runtime, IEnumerable <EVSEStatusRecord> EVSEStatusRecords, StatusCode StatusCode = null, Process_Id?ProcessId = null, HTTPResponse HTTPResponse = null, JObject CustomData = null) : base(Request, ResponseTimestamp, EventTrackingId, Runtime, HTTPResponse, ProcessId, CustomData) { this.EVSEStatusRecords = EVSEStatusRecords ?? throw new ArgumentNullException(nameof(EVSEStatusRecords), "The given enumeration of EVSE status records must not be null!"); this.StatusCode = StatusCode; }
/// <summary> /// Create a new PullEVSEStatus response. /// </summary> /// <param name="Request">A PullEVSEStatus request.</param> /// <param name="ResponseTimestamp">The timestamp of the response creation.</param> /// <param name="EventTrackingId">An optional event tracking identification for correlating this response with other events.</param> /// <param name="Runtime">The runtime of the request/response.</param> /// <param name="OperatorEVSEStatus">An enumeration of EVSE status records grouped by their operators.</param> /// <param name="StatusCode">An optional status code of this response.</param> /// <param name="ProcessId">The optional Hubject process identification of the request.</param> /// <param name="HTTPResponse">The optional HTTP response.</param> /// <param name="CustomData">Optional customer specific data, e.g. in combination with custom parsers and serializers.</param> public PullEVSEStatusResponse(PullEVSEStatusRequest Request, DateTime ResponseTimestamp, EventTracking_Id EventTrackingId, TimeSpan Runtime, IEnumerable <OperatorEVSEStatus> OperatorEVSEStatus, StatusCode StatusCode = null, Process_Id?ProcessId = null, HTTPResponse HTTPResponse = null, JObject CustomData = null) : base(Request, ResponseTimestamp, EventTrackingId, Runtime, HTTPResponse, ProcessId, CustomData) { this.OperatorEVSEStatus = OperatorEVSEStatus ?? throw new ArgumentNullException(nameof(OperatorEVSEStatus), "The given OperatorEVSEStatus must not be null or empty!"); this.StatusCode = StatusCode; }
/// <summary> /// Create a new generic response. /// </summary> /// <param name="Request">The request leading to this result.</param> /// <param name="ResponseTimestamp">The timestamp of the response creation.</param> /// <param name="EventTrackingId">An optional event tracking identification for correlating this response with other events.</param> /// <param name="Runtime">The runtime of the request/response.</param> /// <param name="HTTPResponse">The optional HTTP response.</param> /// <param name="ProcessId">The optional Hubject process identification of the request.</param> /// /// <param name="CustomData">Optional customer-specific data of the response.</param> protected Builder(TRequest Request = null, DateTime?ResponseTimestamp = null, EventTracking_Id EventTrackingId = null, TimeSpan?Runtime = null, HTTPResponse HTTPResponse = null, Process_Id?ProcessId = null, StatusCode StatusCode = null, Boolean?First = null, Boolean?Last = null, UInt32?Number = null, UInt32?NumberOfElements = null, UInt32?Size = null, UInt32?TotalElements = null, UInt32?TotalPages = null, JObject CustomData = null) : base(Request, ResponseTimestamp, EventTrackingId, Runtime, HTTPResponse, ProcessId, CustomData) { this.StatusCode = StatusCode != null?StatusCode.ToBuilder() : new StatusCode.Builder(); this.First = First; this.Last = Last; this.Number = Number; this.NumberOfElements = NumberOfElements; this.Size = Size; this.TotalElements = TotalElements; this.TotalPages = TotalPages; }
/// <summary> /// Try to parse the given JSON representation of a GetChargeDetailRecords response. /// </summary> /// <param name="Request">The request leading to this response.</param> /// <param name="JSON">The JSON to parse.</param> /// <param name="ResponseTimestamp">The timestamp of the response creation.</param> /// <param name="EventTrackingId">An optional event tracking identification for correlating this response with other events.</param> /// <param name="Runtime">The runtime of the request/response.</param> /// <param name="GetChargeDetailRecordsResponse">The parsed GetChargeDetailRecords response.</param> /// <param name="ErrorResponse">An optional error response.</param> /// <param name="ProcessId">The optional Hubject process identification of the request.</param> /// <param name="HTTPResponse">The optional HTTP response.</param> /// <param name="CustomGetChargeDetailRecordsResponseParser">A delegate to parse custom GetChargeDetailRecords response JSON objects.</param> public static Boolean TryParse(GetChargeDetailRecordsRequest Request, JObject JSON, DateTime ResponseTimestamp, EventTracking_Id EventTrackingId, TimeSpan Runtime, out GetChargeDetailRecordsResponse GetChargeDetailRecordsResponse, out String ErrorResponse, HTTPResponse HTTPResponse = null, Process_Id?ProcessId = null, CustomJObjectParserDelegate <GetChargeDetailRecordsResponse> CustomGetChargeDetailRecordsResponseParser = null) { try { GetChargeDetailRecordsResponse = default; if (JSON?.HasValues != true) { ErrorResponse = "The given JSON object must not be null or empty!"; return(false); } #region Parse ChargeDetailRecords [mandatory] if (JSON.ParseOptionalJSON("content", "charge detail records", ChargeDetailRecord.TryParse, out IEnumerable <ChargeDetailRecord> ChargeDetailRecords, out ErrorResponse)) { if (ErrorResponse != null) { return(false); } } #endregion #region Parse StatusCode [optional] if (JSON.ParseOptionalJSON("StatusCode", "StatusCode", OICPv2_3.StatusCode.TryParse, out StatusCode StatusCode, out ErrorResponse)) { if (ErrorResponse != null) { return(false); } } #endregion #region Parse First [optional] if (JSON.ParseOptional("first", "first result", out Boolean? First, out ErrorResponse)) { if (ErrorResponse != null) { return(false); } } #endregion #region Parse Last [optional] if (JSON.ParseOptional("last", "last result", out Boolean? Last, out ErrorResponse)) { if (ErrorResponse != null) { return(false); } } #endregion #region Parse Number [optional] if (JSON.ParseOptional("number", "number", out UInt32? Number, out ErrorResponse)) { if (ErrorResponse != null) { return(false); } } #endregion #region Parse NumberOfElements [optional] if (JSON.ParseOptional("numberOfElements", "number", out UInt32? NumberOfElements, out ErrorResponse)) { if (ErrorResponse != null) { return(false); } } #endregion #region Parse Size [optional] if (JSON.ParseOptional("size", "size", out UInt32? Size, out ErrorResponse)) { if (ErrorResponse != null) { return(false); } } #endregion #region Parse TotalElements [optional] if (JSON.ParseOptional("totalElements", "total elements", out UInt32? TotalElements, out ErrorResponse)) { if (ErrorResponse != null) { return(false); } } #endregion #region Parse TotalPages [optional] if (JSON.ParseOptional("totalPages", "total pages", out UInt32? TotalPages, out ErrorResponse)) { if (ErrorResponse != null) { return(false); } } #endregion #region Parse CustomData [optional] var CustomData = JSON["CustomData"] as JObject; #endregion GetChargeDetailRecordsResponse = new GetChargeDetailRecordsResponse(Request, ResponseTimestamp, EventTrackingId, Runtime, ChargeDetailRecords ?? new ChargeDetailRecord[0], HTTPResponse, ProcessId, StatusCode, First, Last, Number, NumberOfElements, Size, TotalElements, TotalPages, CustomData); if (CustomGetChargeDetailRecordsResponseParser != null) { GetChargeDetailRecordsResponse = CustomGetChargeDetailRecordsResponseParser(JSON, GetChargeDetailRecordsResponse); } return(true); } catch (Exception e) { GetChargeDetailRecordsResponse = default; ErrorResponse = "The given JSON representation of a GetChargeDetailRecords response is invalid: " + e.Message; return(false); } }
/// <summary> /// Try to parse the given JSON representation of a PullEVSEStatus response. /// </summary> /// <param name="Request">The request leading to this response.</param> /// <param name="JSON">The JSON to parse.</param> /// <param name="ResponseTimestamp">The timestamp of the response creation.</param> /// <param name="EventTrackingId">An optional event tracking identification for correlating this response with other events.</param> /// <param name="Runtime">The runtime of the request/response.</param> /// <param name="PullEVSEStatusResponse">The parsed PullEVSEStatus response.</param> /// <param name="ErrorResponse">An optional error response.</param> /// <param name="ProcessId">The optional Hubject process identification of the request.</param> /// <param name="HTTPResponse">The optional HTTP response.</param> /// <param name="CustomPullEVSEStatusResponseParser">A delegate to parse custom PullEVSEStatus response JSON objects.</param> public static Boolean TryParse(PullEVSEStatusRequest Request, JObject JSON, DateTime ResponseTimestamp, EventTracking_Id EventTrackingId, TimeSpan Runtime, out PullEVSEStatusResponse PullEVSEStatusResponse, out String ErrorResponse, Process_Id?ProcessId = null, HTTPResponse HTTPResponse = null, CustomJObjectParserDelegate <PullEVSEStatusResponse> CustomPullEVSEStatusResponseParser = null) { try { PullEVSEStatusResponse = default; if (JSON?.HasValues != true) { ErrorResponse = "The given JSON object must not be null or empty!"; return(false); } #region Parse OperatorEVSEStatus [mandatory] if (!JSON.ParseMandatory("EvseStatuses", "EVSE statuses", out JObject EVSEStatuses, out ErrorResponse)) { return(false); } if (!EVSEStatuses.ParseMandatoryJSON("OperatorEvseStatus", "operator EVSE status", OICPv2_3.OperatorEVSEStatus.TryParse, out IEnumerable <OperatorEVSEStatus> OperatorEVSEStatus, out ErrorResponse)) { return(false); } #endregion #region Parse StatusCode [optional] if (JSON.ParseOptionalJSON("StatusCode", "StatusCode", OICPv2_3.StatusCode.TryParse, out StatusCode StatusCode, out ErrorResponse)) { if (ErrorResponse != null) { return(false); } } #endregion #region Parse CustomData [optional] var CustomData = JSON["CustomData"] as JObject; #endregion PullEVSEStatusResponse = new PullEVSEStatusResponse(Request, ResponseTimestamp, EventTrackingId, Runtime, OperatorEVSEStatus, StatusCode, ProcessId, HTTPResponse, CustomData); if (CustomPullEVSEStatusResponseParser != null) { PullEVSEStatusResponse = CustomPullEVSEStatusResponseParser(JSON, PullEVSEStatusResponse); } return(true); } catch (Exception e) { PullEVSEStatusResponse = default; ErrorResponse = "The given JSON representation of a PullEVSEStatus response is invalid: " + e.Message; return(false); } }
/// <summary> /// The request had some data validation errors. /// </summary> /// <param name="Request">The request.</param> /// <param name="ValidationErrors">Possible request data validation errors.</param> /// <param name="ProcessId">The process identification of the result.</param> public static OICPResult <T> BadRequest(Object Request, ValidationErrorList ValidationErrors = null, Process_Id?ProcessId = null) => new OICPResult <T>(Request,
/// <summary> /// Try to parse the given JSON representation of a PullEVSEData response. /// </summary> /// <param name="Request">The request leading to this response.</param> /// <param name="JSON">The JSON to parse.</param> /// <param name="ResponseTimestamp">The timestamp of the response creation.</param> /// <param name="EventTrackingId">An optional event tracking identification for correlating this response with other events.</param> /// <param name="Runtime">The runtime of the request/response.</param> /// <param name="PullEVSEDataResponse">The parsed PullEVSEData response.</param> /// <param name="ErrorResponse">An optional error response.</param> /// <param name="ProcessId">The optional Hubject process identification of the request.</param> /// <param name="HTTPResponse">The optional HTTP response.</param> /// <param name="CustomPullEVSEDataResponseParser">A delegate to parse custom PullEVSEData response JSON objects.</param> public static Boolean TryParse(PullEVSEDataRequest Request, JObject JSON, DateTime ResponseTimestamp, EventTracking_Id EventTrackingId, TimeSpan Runtime, out PullEVSEDataResponse PullEVSEDataResponse, out String ErrorResponse, Process_Id?ProcessId = null, HTTPResponse HTTPResponse = null, CustomJObjectParserDelegate <PullEVSEDataResponse> CustomPullEVSEDataResponseParser = null) { try { PullEVSEDataResponse = default; if (JSON?.HasValues != true) { ErrorResponse = "The given JSON object must not be null or empty!"; return(false); } #region Parse Content [mandatory] if (!JSON.ParseMandatory("content", "EVSE data content", out JArray EVSEDataRecordsJSON, out ErrorResponse)) { return(false); } var EVSEDataRecords = new List <EVSEDataRecord>(); var Warnings = new List <Warning>(); foreach (var evseDataRecordJSON in EVSEDataRecordsJSON) { try { var ErrorResponse2 = String.Empty; if (evseDataRecordJSON is JObject evseDataRecordJObject && EVSEDataRecord.TryParse(evseDataRecordJObject, out EVSEDataRecord evseDataRecord, out ErrorResponse2)) { EVSEDataRecords.Add(evseDataRecord); } else { if (evseDataRecordJSON is JObject evseDataRecordJObject2) { ErrorResponse2 = "EVSE " + evseDataRecordJObject2["EvseID"]?.Value <String>() + ": " + ErrorResponse2; } Warnings.Add(Warning.Create(I18NString.Create(Languages.en, ErrorResponse2))); } } catch (Exception e) { var message = e.Message; if (evseDataRecordJSON is JObject evseDataRecordJObject2) { message = "EVSE " + evseDataRecordJObject2["EvseID"]?.Value <String>() + ": " + message; } Warnings.Add(Warning.Create(I18NString.Create(Languages.en, message))); } }