Exemplo n.º 1
0
        /// <summary>
        /// Patch this registration and create patch twin model to upload
        /// </summary>
        /// <param name="model"></param>
        /// <param name="disabled"></param>
        public static PublisherRegistration ToPublisherRegistration(
            this PublisherModel model, bool?disabled = null)
        {
            if (model == null)
            {
                throw new ArgumentNullException(nameof(model));
            }
            var deviceId = PublisherModelEx.ParseDeviceId(model.Id,
                                                          out var moduleId);

            return(new PublisherRegistration {
                IsDisabled = disabled,
                DeviceId = deviceId,
                ModuleId = moduleId,
                LogLevel = model.LogLevel,
                JobOrchestratorUrl = model.Configuration?.JobOrchestratorUrl,
                JobCheckInterval = model.Configuration?.JobCheckInterval,
                MaxWorkers = model.Configuration?.MaxWorkers,
                HeartbeatInterval = model.Configuration?.HeartbeatInterval,
                Capabilities = model.Configuration?.Capabilities?
                               .ToDictionary(k => k.Key, v => v.Value),
                Connected = model.Connected ?? false,
                SiteId = model.SiteId,
            });
        }
Exemplo n.º 2
0
 /// <summary>
 /// Equality comparison
 /// </summary>
 /// <param name="model"></param>
 /// <param name="that"></param>
 /// <returns></returns>
 public static bool IsSameAs(this PublisherModel model,
                             PublisherModel that)
 {
     if (model == that)
     {
         return(true);
     }
     if (model == null || that == null)
     {
         return(false);
     }
     return(that.Id == model.Id);
 }
Exemplo n.º 3
0
 /// <summary>
 /// Deep clone
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static PublisherModel Clone(this PublisherModel model)
 {
     if (model == null)
     {
         return(null);
     }
     return(new PublisherModel {
         LogLevel = model.LogLevel,
         Connected = model.Connected,
         Id = model.Id,
         OutOfSync = model.OutOfSync,
         SiteId = model.SiteId
     });
 }
Exemplo n.º 4
0
 /// <summary>
 /// Deep clone
 /// </summary>
 /// <param name="model"></param>
 /// <returns></returns>
 public static PublisherModel Clone(this PublisherModel model)
 {
     if (model == null)
     {
         return(null);
     }
     return(new PublisherModel {
         Certificate = model.Certificate,
         Connected = model.Connected,
         Id = model.Id,
         OutOfSync = model.OutOfSync,
         SiteId = model.SiteId
     });
 }