forked from PowerShell/PowerShell
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStringFormatConverter.cs
More file actions
60 lines (55 loc) · 2.39 KB
/
Copy pathStringFormatConverter.cs
File metadata and controls
60 lines (55 loc) · 2.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
//-----------------------------------------------------------------------
// <copyright file="StringFormatConverter.cs" company="Microsoft">
// Copyright (c) Microsoft Corporation. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------
namespace Microsoft.Management.UI.Internal
{
using System;
using System.Globalization;
using System.Windows.Data;
/// <summary>
/// Formatting string with a given format.
/// </summary>
[System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.MSInternal", "CA903:InternalNamespaceShouldNotContainPublicTypes")]
public class StringFormatConverter : IValueConverter
{
/// <summary>
/// Formatting string with a given format.
/// </summary>
/// <param name="value">The value produced by the binding source.</param>
/// <param name="targetType">The type of the binding target property. This is not used.</param>
/// <param name="parameter">The converter parameter to use. It should be a formatting string.</param>
/// <param name="culture">The culture to use in the converter.</param>
/// <returns>The formatted string.</returns>
public object Convert(object value, Type targetType, Object parameter, CultureInfo culture)
{
if (parameter == null)
{
throw new ArgumentNullException("parameter");
}
string str = (string)value;
string formatString = (string)parameter;
if (String.IsNullOrEmpty(str))
{
return null;
}
return String.Format(culture, formatString, str);
}
/// <summary>
/// Converts a value.
/// </summary>
/// <remarks>
/// This method is not implemented.
/// </remarks>
/// <param name="value">The value that is produced by the binding target.</param>
/// <param name="targetType">The type to convert to.</param>
/// <param name="parameter">The converter parameter to use.</param>
/// <param name="culture">The culture to use in the converter.</param>
/// <returns>A converted value.</returns>
public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
{
throw new NotImplementedException();
}
}
}