Ejemplo n.º 1
0
        internal async Task SetAdapterProperty(ZvsAdapter zvsAdapter, string propertyName, object value, CancellationToken cancellationToken)
        {
            var prop = zvsAdapter.GetType().GetProperty(propertyName);

            if (prop == null)
            {
                await Log.ReportErrorFormatAsync(cancellationToken, "Cannot find property called {0} on this adapter", propertyName);

                return;
            }

            try
            {
                var convertedValue = TypeDescriptor.GetConverter(prop.PropertyType).ConvertFrom(value);
                prop.SetValue(zvsAdapter, convertedValue);
            }
            catch
            {
                Log.ReportErrorFormatAsync(cancellationToken, "Cannot cast value on {0} on this adapter", propertyName).Wait(cancellationToken);
            }
        }
Ejemplo n.º 2
0
        internal async Task SetAdapterProperty(ZvsAdapter zvsAdapter, string propertyName, object value, CancellationToken cancellationToken)
        {
            var prop = zvsAdapter.GetType().GetProperty(propertyName);
            if (prop == null)
            {
                await Log.ReportErrorFormatAsync(cancellationToken, "Cannot find property called {0} on this adapter", propertyName);
                return;
            }

            try
            {
                var convertedValue = TypeDescriptor.GetConverter(prop.PropertyType).ConvertFrom(value);
                prop.SetValue(zvsAdapter, convertedValue);
            }
            catch
            {
                Log.ReportErrorFormatAsync(cancellationToken, "Cannot cast value on {0} on this adapter", propertyName).Wait(cancellationToken);
            }
        }