/// <summary> /// Equality comparison /// </summary> /// <param name="model"></param> /// <param name="that"></param> /// <returns></returns> public static bool IsSameAs(this SupervisorModel model, SupervisorModel that) { if (model == that) { return(true); } if (model == null || that == null) { return(false); } return(that.Id == model.Id); }
/// <summary> /// Deep clone /// </summary> /// <param name="model"></param> /// <returns></returns> public static SupervisorModel Clone(this SupervisorModel model) { if (model == null) { return(null); } return(new SupervisorModel { Certificate = model.Certificate, Connected = model.Connected, Id = model.Id, OutOfSync = model.OutOfSync, SiteId = model.SiteId }); }
/// <summary> /// Deep clone /// </summary> /// <param name="model"></param> /// <returns></returns> public static SupervisorModel Clone(this SupervisorModel model) { if (model == null) { return(null); } return(new SupervisorModel { Connected = model.Connected, Id = model.Id, OutOfSync = model.OutOfSync, LogLevel = model.LogLevel, SiteId = model.SiteId }); }
/// <summary> /// Patch this registration and create patch twin model to upload /// </summary> /// <param name="model"></param> /// <param name="disabled"></param> public static SupervisorRegistration ToSupervisorRegistration( this SupervisorModel model, bool?disabled = null) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var deviceId = SupervisorModelEx.ParseDeviceId(model.Id, out var moduleId); return(new SupervisorRegistration { IsDisabled = disabled, SupervisorId = model.Id, DeviceId = deviceId, ModuleId = moduleId, LogLevel = model.LogLevel, Discovery = model.Discovery ?? DiscoveryMode.Off, AddressRangesToScan = model.DiscoveryConfig?.AddressRangesToScan, NetworkProbeTimeout = model.DiscoveryConfig?.NetworkProbeTimeout, MaxNetworkProbes = model.DiscoveryConfig?.MaxNetworkProbes, PortRangesToScan = model.DiscoveryConfig?.PortRangesToScan, PortProbeTimeout = model.DiscoveryConfig?.PortProbeTimeout, MaxPortProbes = model.DiscoveryConfig?.MaxPortProbes, IdleTimeBetweenScans = model.DiscoveryConfig?.IdleTimeBetweenScans, MinPortProbesPercent = model.DiscoveryConfig?.MinPortProbesPercent, Certificate = model.Certificate?.EncodeAsDictionary(), DiscoveryCallbacks = model.DiscoveryConfig?.Callbacks. EncodeAsDictionary(), SecurityModeFilter = model.DiscoveryConfig?.ActivationFilter?. SecurityMode, TrustListsFilter = model.DiscoveryConfig?.ActivationFilter?. TrustLists.EncodeAsDictionary(), SecurityPoliciesFilter = model.DiscoveryConfig?.ActivationFilter?. SecurityPolicies.EncodeAsDictionary(), DiscoveryUrls = model.DiscoveryConfig?.DiscoveryUrls?. EncodeAsDictionary(), Locales = model.DiscoveryConfig?.Locales?. EncodeAsDictionary(), Connected = model.Connected ?? false, Thumbprint = model.Certificate?.ToSha1Hash(), SiteId = model.SiteId, }); }
/// <summary> /// Patch this registration and create patch twin model to upload /// </summary> /// <param name="model"></param> /// <param name="disabled"></param> public static SupervisorRegistration ToSupervisorRegistration( this SupervisorModel model, bool?disabled = null) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var deviceId = SupervisorModelEx.ParseDeviceId(model.Id, out var moduleId); return(new SupervisorRegistration { IsDisabled = disabled, DeviceId = deviceId, ModuleId = moduleId, LogLevel = model.LogLevel, Connected = model.Connected ?? false, SiteId = model.SiteId, }); }
/// <summary> /// Patch this registration and create patch twin model to upload /// </summary> /// <param name="model"></param> /// <param name="disabled"></param> public static SupervisorRegistration ToSupervisorRegistration( this SupervisorModel model, bool?disabled = null) { if (model == null) { throw new ArgumentNullException(nameof(model)); } var deviceId = SupervisorModelEx.ParseDeviceId(model.Id, out var moduleId); return(new SupervisorRegistration { IsDisabled = disabled, DeviceId = deviceId, ModuleId = moduleId, LogLevel = model.LogLevel, Certificate = model.Certificate?.EncodeAsDictionary(), Connected = model.Connected ?? false, Thumbprint = model.Certificate?.ToSha1Hash(), SiteId = model.SiteId, }); }