[corlib] Avoid unnecessary ephemeron array resizes
[mono.git] / mcs / class / referencesource / System.Activities.Presentation / System.Activities.Presentation / System / Activities / Presentation / Base / Core / Internal / PropertyEditing / FromExpression / Framework / Data / BoolToDoubleConverter.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.ComponentModel;
9     using System.Globalization;
10     using System.Reflection;
11     using System.Windows;
12     using System.Windows.Controls;
13     using System.Windows.Data;
14     using System.Diagnostics.CodeAnalysis;
15     using System.Runtime;
16
17     // <summary>
18     // Maps a bool to a FontWeight. True becomes Bold, and False is Normal.
19     // </summary>
20
21     [SuppressMessage("Microsoft.Performance", "CA1812:AvoidUninstantiatedInternalClasses")]
22     internal class BoolToDoubleConverter : IValueConverter
23     {
24         // Private Fields
25
26         private double trueValue = 0;
27         private double falseValue = 0;
28
29         // Public Properties
30
31         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
32         public double TrueValue
33         {
34             get
35             {
36                 return this.trueValue;
37             }
38             set
39             {
40                 this.trueValue = value;
41             }
42         }
43
44         [System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Performance", "CA1811:AvoidUncalledPrivateCode")]
45         public double FalseValue
46         {
47             get
48             {
49                 return this.falseValue;
50             }
51             set
52             {
53                 this.falseValue = value;
54             }
55         }
56
57
58         // IValueConverter Implementation
59
60         public object ConvertBack(object o, Type targetType, object parameter, CultureInfo culture)
61         {
62             Fx.Assert(false, "Never expecting the inverse transform to be called");
63             return null;
64         }
65
66         public object Convert(object o, Type targetType, object parameter, CultureInfo culture)
67         {
68             Fx.Assert(o is bool, "Ensure that transformed element is a boolean");
69
70             if ((bool)o)
71             {
72                 return this.trueValue;
73             }
74             else
75             {
76                 return this.falseValue;
77             }
78         }
79
80     }
81 }