Example #1
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            SnoopParameterInformation paramInfo = (SnoopParameterInformation)value;
            Type t = paramInfo.DeclaringType;

            //var fields = t.GetFields(System.Reflection.BindingFlags.FlattenHierarchy);
            var fields = t.GetFields(BindingFlags.FlattenHierarchy | BindingFlags.Public | BindingFlags.Static);

            var dpType = typeof(DependencyProperty);

            List <DependencyPropertyNameValuePair> dependencyProperties = new List <DependencyPropertyNameValuePair>();

            foreach (var field in fields)
            {
                if (dpType.IsAssignableFrom(field.FieldType))
                {
                    dependencyProperties.Add(new DependencyPropertyNameValuePair()
                    {
                        DependencyPropertyName = field.Name, DependencyProperty = (DependencyProperty)field.GetValue(null)
                    });
                }
            }

            dependencyProperties.Sort();

            return(dependencyProperties);
        }
Example #2
0
        public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            SnoopParameterInformation paramInfo = value as SnoopParameterInformation;

            if (paramInfo == null)
            {
                return(value);
            }

            var converter = TypeDescriptor.GetConverter(paramInfo.ParameterType);

            var result = converter.ConvertFrom(paramInfo.ParameterValue);

            return(result);
        }