Exemplo n.º 1
0
        internal async Task SetPluginProperty(ZvsPlugin zvsPlugin, string propertyName, object value, CancellationToken cancellationToken)
        {
            var prop = zvsPlugin.GetType().GetProperty(propertyName);

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

                return;
            }

            try
            {
                var convertedValue = TypeDescriptor.GetConverter(prop.PropertyType).ConvertFrom(value);
                prop.SetValue(zvsPlugin, convertedValue);
            }
            catch
            {
                Log.ReportErrorFormatAsync(cancellationToken, "Cannot cast value on {0} on this plugin", propertyName).Wait(cancellationToken);
            }
        }
Exemplo n.º 2
0
        internal async Task SetPluginProperty(ZvsPlugin zvsPlugin, string propertyName, object value, CancellationToken cancellationToken)
        {
            var prop = zvsPlugin.GetType().GetProperty(propertyName);
            if (prop == null)
            {
                await Log.ReportErrorFormatAsync(cancellationToken, "Cannot find property called {0} on this plug-in", propertyName);
                return;
            }

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