/// <summary> /// Deep clone /// </summary> /// <param name="model"></param> /// <returns></returns> public static GatewayModel Clone(this GatewayModel model) { if (model == null) { return(null); } return(new GatewayModel { Connected = model.Connected, Id = model.Id, SiteId = model.SiteId }); }
/// <summary> /// Equality comparison /// </summary> /// <param name="model"></param> /// <param name="that"></param> /// <returns></returns> public static bool IsSameAs(this GatewayModel model, GatewayModel that) { if (model == that) { return(true); } if (model == null || that == null) { return(false); } return(that.Id == model.Id); }
/// <summary> /// Patch this registration and create patch twin model to upload /// </summary> /// <param name="model"></param> /// <param name="disabled"></param> public static GatewayRegistration ToGatewayRegistration( this GatewayModel model, bool?disabled = null) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var deviceId = model.Id; return(new GatewayRegistration { IsDisabled = disabled, DeviceId = deviceId, Connected = model.Connected ?? false, SiteId = model.SiteId, }); }