public async Task <Twin> GetTwinAsync()
 {
     if (client == null)
     {
         return(await mockClient.GetTwinAsync());
     }
     else
     {
         return(await client.GetTwinAsync());
     }
 }
示例#2
0
        public async Task <T> ReadDesiredComponentPropertyAsync <T>(string componentName, string propertyName)
        {
            var twin = await deviceClient.GetTwinAsync();

            var desiredPropertyValue = twin.Properties.Desired.GetPropertyValue <T>(componentName, propertyName);

            if (Comparer <T> .Default.Compare(desiredPropertyValue, default(T)) > 0)
            {
                await AckDesiredPropertyReadAsync(componentName, propertyName, desiredPropertyValue, StatusCodes.Completed, "update complete", twin.Properties.Desired.Version);
            }
            return(desiredPropertyValue);
        }