[amd64/tramp] hide interpreter specific trampoline behind ifdef
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / View / ModelPropertyPathExpanderConverter.cs
1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //----------------------------------------------------------------
4
5 namespace System.Activities.Presentation.View
6 {
7     using System;
8     using System.Activities.Presentation.Internal.PropertyEditing.Model;
9     using System.Activities.Presentation.Model;
10     using System.Globalization;
11     using System.Text;
12     using System.Windows.Data;
13
14     sealed class ModelPropertyPathExpanderConverter : IValueConverter 
15     {
16         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
17         {
18             string result = null;
19
20             if (value != null)
21             {
22                 ModelPropertyEntry modelPropertyEntry = value as ModelPropertyEntry;
23                 if (modelPropertyEntry != null)
24                 {
25                     StringBuilder propertyPath = new StringBuilder(modelPropertyEntry.PropertyName);
26                     propertyPath.Insert(0, '.');
27
28                     ModelProperty property = modelPropertyEntry.FirstModelProperty;
29                     if (property != null)
30                     {
31                         ModelItem convertedValue = property.Parent;
32                         while (convertedValue != null && !typeof(Activity).IsAssignableFrom(convertedValue.ItemType))
33                         {
34                             if (null != convertedValue.Source)
35                             {
36                                 propertyPath.Insert(0, convertedValue.Source.Name);
37                                 propertyPath.Insert(0, '.');
38                             }
39                             convertedValue = convertedValue.Parent;
40                         }
41                     }
42                     propertyPath.Remove(0, 1);
43                     result = propertyPath.ToString();
44                 }
45             }
46             return result;
47         }
48
49         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
50         {
51             throw FxTrace.Exception.AsError( new NotSupportedException(SR.NonSupportedModelPropertyPathExpanderConverterConvertBack));
52         }
53     }
54 }