NullableBoolConverter.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ 4.0 / 4.0 / untmp / DEVDIV_TFS / Dev10 / Releases / RTMRel / wpf / src / Framework / System / Windows / NullableBoolConverter.cs / 1305600 / NullableBoolConverter.cs

                            //---------------------------------------------------------------------------- 
//
// Copyright (C) Microsoft Corporation.  All rights reserved.
//
//--------------------------------------------------------------------------- 

using System; 
using System.ComponentModel; 
using System.Collections;
 
namespace System.Windows
{

    ///  
    /// NullableBoolConverter - Converter class for converting instances of other types to and from bool to Nullable bool.
    ///  
    public class NullableBoolConverter: NullableConverter 
    {
        ///  
        /// Construct NullableConverter converter for bool type
        /// 
        public NullableBoolConverter()
            : base(typeof(bool?)) 
        {
        } 
 

        ///  
        /// Returns whether this object supports a standard set of values that can be
        /// picked from a list, using the specified context.
        /// 
        /// An ITypeDescriptorContext that provides a format context. 
        /// 
        ///     true if GetStandardValues should be called to find a common set 
        ///     of values the object supports; otherwise, false. 
        /// 
        public override bool GetStandardValuesSupported(ITypeDescriptorContext context) 
        {
            return true;
        }
 
        /// 
        ///     As implemented in this class, this method always returns true. 
        /// If the list is exclusive, such as in an enumeration data type, then no other values are valid. If the list is not exclusive, then other valid values might exist in addition to the list of standard values that GetStandardValues provides. 
        /// 
        ///  
        /// Returns whether the collection of standard values returned from GetStandardValues is an exclusive list of possible values, using the specified context.
        /// 
        public override bool GetStandardValuesExclusive(ITypeDescriptorContext context)
        { 
            return true;
        } 
 
        /// 
        /// StandardValuesCollection method override 
        /// 
        /// ITypeDescriptorContext
        /// TypeConverter.StandardValuesCollection
        public override TypeConverter.StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) 
        {
            if (_standardValues == null) 
            { 
                ArrayList list1 = new ArrayList(3);
                list1.Add((bool?)true); 
                list1.Add((bool?)false);
                list1.Add((bool?)null);
                _standardValues = new TypeConverter.StandardValuesCollection(list1.ToArray());
            } 
            return _standardValues;
        } 
 
        /// 
        /// Cached value for GetStandardValues 
        /// 
        [ThreadStatic]
        private static TypeConverter.StandardValuesCollection _standardValues;
    } 
}

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
// Copyright (c) Microsoft Corporation. All rights reserved.


                        

Link Menu

Network programming in C#, Network Programming in VB.NET, Network Programming in .NET
This book is available now!
Buy at Amazon US or
Buy at Amazon UK