[reflection] Coop handles icalls in System.Reflection and System.RuntimeTypeHandle...
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Base / Core / Internal / PropertyEditing / Editors / newitemfactorytypemodeltotypenameconverter.cs
1 //----------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation.  All rights reserved.
3 //----------------------------------------------------------------
4 namespace System.Activities.Presentation.Internal.PropertyEditing.Editors 
5 {
6     using System;
7     using System.Windows.Data;
8     using System.Globalization;
9
10     using System.Activities.Presentation.Internal.PropertyEditing.FromExpression.Framework.PropertyInspector;
11     using System.Activities.Presentation;
12
13     // <summary>
14     // Converts an instance of NewItemFactoryTypeModel to its contained Type name.
15     // </summary>
16     internal class NewItemFactoryTypeModelToTypeNameConverter : IValueConverter 
17     {
18
19         // Converts an instance of NewItemFactoryTypeModel to its corresponding type name
20         public object Convert(object value, Type targetType, object parameter, CultureInfo culture) 
21         {
22
23             if (typeof(string).IsAssignableFrom(targetType)) 
24             {
25                 NewItemFactoryTypeModel model = value as NewItemFactoryTypeModel;
26                 if (model != null && model.Type != null) 
27                 {
28                     return model.Type.Name;
29                 }
30             }
31
32             return string.Empty;
33         }
34
35         // This class is only a one-way converter
36         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture) 
37         {
38             throw FxTrace.Exception.AsError(new InvalidOperationException());
39         }
40     }
41 }