예제 #1
0
        /// <inheritdoc/>
        public async Task <PublisherModel> GetPublisherAsync(string id,
                                                             bool onlyServerState, CancellationToken ct)
        {
            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentException(nameof(id));
            }
            var deviceId = PublisherModelEx.ParseDeviceId(id, out var moduleId);
            var device   = await _iothub.GetAsync(deviceId, moduleId, ct);

            var registration = device.ToEntityRegistration(onlyServerState)
                               as PublisherRegistration;

            if (registration == null)
            {
                throw new ResourceNotFoundException(
                          $"{id} is not a supervisor registration.");
            }
            return(registration.ToServiceModel());
        }