[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 / FromExpression / Framework / Data / IntegerToVisibilityConverter.cs
1 // -------------------------------------------------------------------
2 // Copyright (c) Microsoft Corporation. All Rights Reserved.
3 // -------------------------------------------------------------------
4 //From \\authoring\Sparkle\Source\1.0.1083.0\Common\Source\Framework\Data
5 namespace System.Activities.Presentation.Internal.PropertyEditing.FromExpression.Framework.Data
6 {
7     using System;
8     using System.Collections;
9     using System.ComponentModel;
10     using System.Globalization;
11     using System.Reflection;
12     using System.Windows;
13     using System.Windows.Controls;
14     using System.Windows.Data;
15     using System.Diagnostics.CodeAnalysis;
16     using System.Runtime;
17
18     // <summary>
19     // Maps an Integer to Visilbity. 0 becomes Hidden, non-zero becomes Visible.
20     // </summary>
21     [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")]
22     internal class IntegerToVisibilityConverter : IValueConverter
23     {
24         private Visibility zeroValue = Visibility.Collapsed;
25
26         private Visibility nonzeroValue = Visibility.Visible;
27         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
28         public Visibility ZeroValue
29         {
30             get { return this.zeroValue; }
31             set { this.zeroValue = value; }
32         }
33         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
34         public Visibility NonzeroValue
35         {
36             get { return this.nonzeroValue; }
37             set { this.nonzeroValue = value; }
38         }
39
40         // IValueConverter Implementation
41
42         public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
43         {
44             Fx.Assert(false, "Never expecting the inverse transform to be called");
45             return null;
46         }
47
48         public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
49         {
50             Fx.Assert(value is int, "Ensure that transformed value is an integer");
51
52             if ((value is int) && (int)value == 0)
53             {
54                 return this.zeroValue;
55             }
56             else
57             {
58                 return this.nonzeroValue;
59             }
60         }
61     }
62 }