Пример #1
0
        /// <inheritdoc/>
        public async Task <WriteResultModel> NodeWriteAsync(
            EndpointApiModel endpoint, WriteRequestModel request)
        {
            var result = await _client.NodeWriteAsync(endpoint,
                                                      request.Map <WriteRequestApiModel>());

            return(result.Map <WriteResultModel>());
        }
Пример #2
0
        /// <inheritdoc/>
        public async Task <WriteResultModel> NodeWriteAsync(
            string endpoint, WriteRequestModel request)
        {
            var result = await _client.NodeWriteAsync(endpoint,
                                                      Map <WriteRequestApiModel>(request));

            return(Map <WriteResultModel>(result));
        }
Пример #3
0
        /// <inheritdoc/>
        public async Task <WriteResultModel> NodeWriteAsync(
            string endpoint, WriteRequestModel request)
        {
            var result = await _client.NodeWriteAsync(endpoint,
                                                      request.ToApiModel());

            return(result.ToServiceModel());
        }
 /// <summary>
 /// Create from service model
 /// </summary>
 /// <param name="model"></param>
 public WriteRequestApiModel(WriteRequestModel model)
 {
     if (model == null)
     {
         throw new ArgumentNullException(nameof(model));
     }
     Attributes = model.Attributes?
                  .Select(a => a == null ? null : new AttributeWriteRequestApiModel(a))
                  .ToList();
     Header = model.Header == null ? null :
              new RequestHeaderApiModel(model.Header);
 }
Пример #5
0
 /// <summary>
 /// Create from service model
 /// </summary>
 /// <param name="model"></param>
 public static WriteRequestApiModel ToApiModel(
     this WriteRequestModel model)
 {
     if (model == null)
     {
         return(null);
     }
     return(new WriteRequestApiModel {
         Attributes = model.Attributes?
                      .Select(a => a.ToApiModel())
                      .ToList(),
         Header = model.Header.ToApiModel()
     });
 }
Пример #6
0
 /// <inheritdoc/>
 public async Task <WriteResultModel> NodeWriteAsync(
     string endpointId, WriteRequestModel request)
 {
     if (request == null)
     {
         throw new ArgumentNullException(nameof(request));
     }
     if (request.Attributes == null || request.Attributes.Count == 0)
     {
         throw new ArgumentNullException(nameof(request.Attributes));
     }
     if (request.Attributes.Any(r => string.IsNullOrEmpty(r.NodeId)))
     {
         throw new ArgumentException(nameof(request.Attributes));
     }
     return(await CallServiceOnTwin <WriteRequestModel, WriteResultModel>(
                "NodeWrite_V2", endpointId, request));
 }
        /// <inheritdoc/>
        public async Task <WriteResultModel> NodeWriteAsync(
            EndpointRegistrationModel registration, WriteRequestModel request)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }
            if (request.Attributes == null || request.Attributes.Count == 0)
            {
                throw new ArgumentNullException(nameof(request.Attributes));
            }
            if (request.Attributes.Any(r => string.IsNullOrEmpty(r.NodeId)))
            {
                throw new ArgumentException(nameof(request.Attributes));
            }
            var result = await CallServiceOnSupervisorAsync <WriteRequestModel, WriteResultModel>(
                "NodeWrite_V2", registration, request);

            return(result);
        }
Пример #8
0
 /// <inheritdoc/>
 public Task <WriteResultModel> NodeWriteAsync(
     string endpointId, WriteRequestModel request)
 {
     return(_nodes.NodeWriteAsync(Endpoint, request));
 }