937d322065453526027368adb57aa4839db82977
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / View / TypeToArgumentTypeConverter.cs
1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //----------------------------------------------------------------
4
5 namespace System.Activities.Presentation.View
6 {
7     using System.Diagnostics;
8     using System.Globalization;
9     using System.Windows.Data;
10     using System.Activities.Presentation.Model;
11     using System.Runtime;
12
13     // This converter converts from InArgument<T>, OutArgument<T>, Activity<T> to T
14     // this does not support convert back.
15     internal sealed class TypeToArgumentTypeConverter : IValueConverter
16     {
17         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
18         {
19             object convertedValue = null;
20             Type type = value as Type;
21             if (type != null)
22             {
23                 if (type.GetGenericArguments().Length > 0)
24                 {
25                     convertedValue = type.GetGenericArguments()[0];
26                 }
27             }
28             return convertedValue;
29         }
30
31         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
32         {
33             throw FxTrace.Exception.AsError(new NotSupportedException());
34         }
35     }
36 }