sharee.bike-App/SharedBusinessLogic/Services/CopriApi/Result.cs

39 lines
1.2 KiB
C#
Raw Permalink Normal View History

2023-04-19 12:14:14 +02:00
using System;
2024-04-09 12:53:23 +02:00
using ShareeBike.Services.CopriApi;
2021-05-13 20:03:07 +02:00
2024-04-09 12:53:23 +02:00
namespace ShareeBike.Model.Services.CopriApi
2021-05-13 20:03:07 +02:00
{
2022-09-06 16:08:19 +02:00
public class Result<T> where T : class
{
/// <summary>
/// Constructs a result object.
/// </summary>
/// <param name="source">Type of source (data provider).</param>
/// <param name="response">Requested data (bikes, station).</param>
2023-04-19 12:14:14 +02:00
/// <param name="generalData">General data (common to all responses).</param>
2022-09-06 16:08:19 +02:00
public Result(
Type source,
T response,
GeneralData generalData,
Exception exception = null)
{
Source = source ?? throw new ArgumentException(nameof(source));
Response = response ?? throw new ArgumentException(nameof(response));
GeneralData = generalData ?? new GeneralData();
Exception = exception;
}
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Holds the requested data (bikes, stations and bikes).</summary>
public T Response { get; }
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Holds the general purpose data (common to all responses).</summary>
public GeneralData GeneralData { get; }
2022-01-04 18:54:03 +01:00
2022-09-06 16:08:19 +02:00
/// <summary> Specifies the source (type of provider) of the copri response.</summary>
public Type Source { get; }
2021-05-13 20:03:07 +02:00
2022-09-06 16:08:19 +02:00
/// <summary> Holds the exception if a communication error occurred.</summary>
public Exception Exception { get; private set; }
}
2021-05-13 20:03:07 +02:00
}