1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All rights reserved.
3 //----------------------------------------------------------------
4 namespace System.Activities.Presentation.Internal.PropertyEditing.Automation
7 using System.Diagnostics.CodeAnalysis;
8 using System.Globalization;
9 using System.Windows.Data;
10 using System.Activities.Presentation;
13 // Simple converter that uses a format string to convert a value into a display string
14 // This class is referenced in XAML.
16 [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")]
17 internal class TextFormatConverter : IValueConverter
20 private string _format;
23 // Gets or sets the format string to apply
25 [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
36 // IValueConverter Members
38 public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
40 value = value ?? "null";
41 return string.Format(culture ?? CultureInfo.CurrentCulture, _format ?? "{0}", value.ToString());
44 public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
46 throw FxTrace.Exception.AsError(new InvalidOperationException());