1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
5 namespace System.Activities.Presentation.View
8 using System.Activities.Presentation.Internal.PropertyEditing.Model;
9 using System.Activities.Presentation.Model;
10 using System.Globalization;
12 using System.Windows.Data;
14 sealed class ModelPropertyPathExpanderConverter : IValueConverter
16 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
22 ModelPropertyEntry modelPropertyEntry = value as ModelPropertyEntry;
23 if (modelPropertyEntry != null)
25 StringBuilder propertyPath = new StringBuilder(modelPropertyEntry.PropertyName);
26 propertyPath.Insert(0, '.');
28 ModelProperty property = modelPropertyEntry.FirstModelProperty;
31 ModelItem convertedValue = property.Parent;
32 while (convertedValue != null && !typeof(Activity).IsAssignableFrom(convertedValue.ItemType))
34 if (null != convertedValue.Source)
36 propertyPath.Insert(0, convertedValue.Source.Name);
37 propertyPath.Insert(0, '.');
39 convertedValue = convertedValue.Parent;
42 propertyPath.Remove(0, 1);
43 result = propertyPath.ToString();
49 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
51 throw FxTrace.Exception.AsError( new NotSupportedException(SR.NonSupportedModelPropertyPathExpanderConverterConvertBack));