Ejemplo n.º 1
0
 /// <inheritdoc/>
 public void Provide(IBindingProviderBuilder builder)
 {
     if (!IoTEdgeHelpers.IsRunningInIotEdge())
     {
         builder.Bind <ICommunicationClient>().To <NullCommunicationClient>();
     }
     else
     {
         builder.Bind <ICommunicationClient>().To <CommunicationClient>();
     }
 }
        /// <inheritdoc/>
        public bool CanProvide(Type type)
        {
            if (!IoTEdgeHelpers.IsRunningInIotEdge())
            {
                return(false);
            }

            if (_twin == null)
            {
                var client = _getContainer().Get <ModuleClient>();
                client.GetTwinAsync()
                .ContinueWith(_ => _twin = _.Result)
                .Wait();

                _logger.Information($"Desired properties : {_twin.Properties.Desired.ToJson()}");
            }

            var name = type.GetFriendlyConfigurationName().ToCamelCase();

            _logger.Information($"Ask for providing {name}");
            return(_twin.Properties.Desired.Contains(name));
        }