1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
5 namespace System.ServiceModel.Activities.Presentation
8 using System.Globalization;
9 using System.Windows.Data;
10 using System.Activities.Presentation.Model;
11 using System.Activities;
12 using System.Activities.Core.Presentation;
14 sealed class ActivityXRefConverter : IValueConverter
16 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
18 if (!(targetType == typeof(string) || targetType == typeof(object)))
20 throw FxTrace.Exception.AsError(new NotSupportedException());
24 throw FxTrace.Exception.AsError(new ArgumentNullException("value"));
26 ModelItem activity = value as ModelItem;
27 string displayName = value as string;
29 string formatString = (parameter as string) ?? "{0}";
31 if (null != activity && typeof(Activity).IsAssignableFrom(activity.ItemType))
33 displayName = ((string)activity.Properties["DisplayName"].ComputedValue);
36 if (null == displayName)
38 displayName = "<null>";
40 else if (displayName.Length == 0)
45 return string.Format(CultureInfo.CurrentUICulture, formatString, displayName);
48 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
50 throw FxTrace.Exception.AsError(new NotSupportedException());