// Copyright (c) Microsoft Corporation. // Licensed under the MIT License. using System; using System.Globalization; using System.Windows.Data; namespace Microsoft.Management.UI.Internal { /// /// Formatting string with a given format. /// [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")] public class StringFormatConverter : IValueConverter { /// /// Formatting string with a given format. /// /// The value produced by the binding source. /// The type of the binding target property. This is not used. /// The converter parameter to use. It should be a formatting string. /// The culture to use in the converter. /// The formatted string. public object Convert(object value, Type targetType, Object parameter, CultureInfo culture) { ArgumentNullException.ThrowIfNull(parameter); string str = (string)value; string formatString = (string)parameter; if (string.IsNullOrEmpty(str)) { return null; } return string.Format(culture, formatString, str); } /// /// Converts a value. /// /// /// This method is not implemented. /// /// The value that is produced by the binding target. /// The type to convert to. /// The converter parameter to use. /// The culture to use in the converter. /// A converted value. public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) { throw new NotImplementedException(); } } }