Mono exception to SocketException
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Core.Presentation / System / ServiceModel / Activities / Presentation / ContentButtonTitleConverter.cs
1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //----------------------------------------------------------------
4
5 namespace System.ServiceModel.Activities.Presentation
6 {
7     using System.Runtime;
8     using System.Activities.Core.Presentation;
9     using System.Activities.Presentation.Model;
10     using System.Globalization;
11     using System.Windows.Data;
12
13     sealed class ContentButtonTitleConverter : IValueConverter
14     {
15         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
16         {
17             object content = value;
18             if (content != null && content is ModelItem)
19             {
20                 content = ((ModelItem)content).GetCurrentValue();
21             }
22             if (content == null)
23             {
24                 return SR.DefineContent;
25             }
26             else
27             {
28                 //string contentTypeName = content.GetType().Name;
29                 if (content is ReceiveMessageContent || content is SendMessageContent)
30                 {
31                     return SR.ViewMessageContent;
32                 }
33                 else if (content is ReceiveParametersContent || content is SendParametersContent)
34                 {
35                     return SR.ViewParameterContent;
36                 }
37                 else
38                 {
39                     Fx.Assert(false, "Content must be of either ReceiveMessageContent, ReceiveParametersContent, SendMessageContent or SendParametersContent.");
40                     return null;
41                 }
42             }
43         }
44
45         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
46         {
47             throw FxTrace.Exception.AsError(new NotSupportedException());
48         }
49     }
50 }