1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
5 namespace System.Activities.Presentation.View
8 using System.Collections.Generic;
9 using System.Diagnostics.CodeAnalysis;
10 using System.Globalization;
11 using System.Reflection;
12 using System.Windows.Data;
13 using System.Activities.Presentation.Model;
14 using System.Activities.Presentation.PropertyEditing;
15 using System.Activities.Presentation.Internal.PropertyEditing.Model;
18 sealed class PropertyEntryToEditorOptionConverter : IValueConverter
20 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
22 PropertyEntry propertyEntry = value as PropertyEntry;
23 if (null == propertyEntry)
25 PropertyValue propertyValue = value as PropertyValue;
26 if (null != propertyValue)
28 propertyEntry = propertyValue.ParentProperty;
32 ModelPropertyEntry modelPropertyEntry = propertyEntry as ModelPropertyEntry;
34 ModelProperty modelProperty = null;
35 if (modelPropertyEntry != null)
37 modelProperty = modelPropertyEntry.FirstModelProperty;
40 if (modelProperty == null)
42 return Binding.DoNothing;
45 string optionName = parameter as string;
46 if (optionName == null)
48 return Binding.DoNothing;
52 if (EditorOptionAttribute.TryGetOptionValue(modelProperty.Attributes, optionName, out optionValue))
57 return Binding.DoNothing;
60 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
62 // It is simply impossible to convert back.
63 throw FxTrace.Exception.AsError(new NotSupportedException());