/// <summary> /// Create from service model /// </summary> /// <param name="model"></param> public ReadEventsDetailsApiModel(ReadEventsDetailsModel model) { if (model == null) { throw new ArgumentNullException(nameof(model)); } StartTime = model.StartTime; EndTime = model.EndTime; NumEvents = model.NumEvents; Filter = model.Filter; }
/// <summary> /// Create api model /// </summary> public static ReadEventsDetailsApiModel ToApiModel( this ReadEventsDetailsModel model) { if (model == null) { return(null); } return(new ReadEventsDetailsApiModel { EndTime = model.EndTime, StartTime = model.StartTime, NumEvents = model.NumEvents, Filter = model.Filter.ToApiModel() }); }
/// <summary> /// Convert read event details /// </summary> /// <param name="codec"></param> /// <param name="details"></param> /// <returns></returns> public static JToken Encode(this IVariantEncoder codec, ReadEventsDetailsModel details) { if (details == null) { throw new ArgumentNullException(nameof(details)); } if (details.EndTime == null && details.StartTime == null) { throw new ArgumentException("Start time and end time cannot both be null", nameof(details)); } if ((details.StartTime == null || details.EndTime == null) && ((details.NumEvents ?? 0) == 0)) { throw new ArgumentException("Value bound must be set", nameof(details.NumEvents)); } return(codec.Encode(new ExtensionObject(new ReadEventDetails { EndTime = details.EndTime ?? DateTime.MinValue, StartTime = details.StartTime ?? DateTime.MinValue, Filter = codec.Decode(details.Filter), NumValuesPerNode = details.NumEvents ?? 0 }))); }