1 //----------------------------------------------------------------
2 // <copyright company="Microsoft Corporation">
3 // Copyright (c) Microsoft Corporation. All rights reserved.
5 //----------------------------------------------------------------
7 namespace System.Activities.Presentation.Converters
9 using System.Activities.Presentation.Model;
10 using System.Globalization;
13 using System.Windows.Data;
14 using Microsoft.Activities.Presentation;
16 internal class OutlineViewTextConverter : IMultiValueConverter
18 public object Convert(object[] values, Type targetType, object parameter, CultureInfo culture)
20 string displayName = string.Empty;
21 if (values[0] != DependencyProperty.UnsetValue)
23 displayName = values[0] as string;
26 if (string.IsNullOrEmpty(displayName) && values[1] != DependencyProperty.UnsetValue)
28 ModelItem modelItem = values[1] as ModelItem;
29 if (modelItem != null)
31 ModelProperty nameProperty = modelItem.Properties["Name"];
32 if (nameProperty != null && nameProperty.Value != null)
34 displayName = nameProperty.Value.GetCurrentValue() as string;
37 if (string.IsNullOrEmpty(displayName))
39 Fx.Assert(modelItem.ItemType != null && modelItem.ItemType.Name != null, "ModelItem should always have a name");
40 displayName = TypeNameHelper.GetDisplayName(modelItem.ItemType, false);
48 public object[] ConvertBack(object value, Type[] targetTypes, object parameter, CultureInfo culture)
50 throw FxTrace.Exception.AsError(new InvalidOperationException());