CollectionConverter.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Dotnetfx_Vista_SP2 / Dotnetfx_Vista_SP2 / 8.0.50727.4016 / DEVDIV / depot / DevDiv / releases / whidbey / NetFxQFE / ndp / fx / src / CompMod / System / ComponentModel / CollectionConverter.cs / 1 / CollectionConverter.cs

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

/* 
 */ 
namespace System.ComponentModel {
    using Microsoft.Win32; 
    using System.Collections;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Globalization; 
    using System.Runtime.Serialization.Formatters;
    using System.Runtime.Remoting; 
    using System.Runtime.InteropServices; 
    using System.Security.Permissions;
 
    /// 
    ///    Provides a type converter to convert
    ///       collection objects to and from various other representations.
    ///  
    [HostProtection(SharedState = true)]
    public class CollectionConverter : TypeConverter 
    { 

        ///  
        ///    Converts the given
        ///       value object to the
        ///       specified destination type.
        ///  
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
            if (destinationType == null) { 
                throw new ArgumentNullException("destinationType"); 
            }
 
            if (destinationType == typeof(string)) {
                if (value is ICollection) {
                    return SR.GetString(SR.CollectionConverterText);
                } 
            }
 
            return base.ConvertTo(context, culture, value, destinationType); 
        }
 
        /// 
        ///    Gets a collection of properties for
        ///       the type of array specified by the value parameter using the specified context and
        ///       attributes. 
        /// 
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { 
            //return new PropertyDescriptorCollection(null); 
            return null;
        } 

        /// 
        ///    Gets a value indicating whether this object
        ///       supports properties. 
        /// 
        public override bool GetPropertiesSupported(ITypeDescriptorContext context) { 
            return false; 
        }
 

    }
}
 

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

/* 
 */ 
namespace System.ComponentModel {
    using Microsoft.Win32; 
    using System.Collections;
    using System.ComponentModel;
    using System.Diagnostics;
    using System.Globalization; 
    using System.Runtime.Serialization.Formatters;
    using System.Runtime.Remoting; 
    using System.Runtime.InteropServices; 
    using System.Security.Permissions;
 
    /// 
    ///    Provides a type converter to convert
    ///       collection objects to and from various other representations.
    ///  
    [HostProtection(SharedState = true)]
    public class CollectionConverter : TypeConverter 
    { 

        ///  
        ///    Converts the given
        ///       value object to the
        ///       specified destination type.
        ///  
        public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType) {
            if (destinationType == null) { 
                throw new ArgumentNullException("destinationType"); 
            }
 
            if (destinationType == typeof(string)) {
                if (value is ICollection) {
                    return SR.GetString(SR.CollectionConverterText);
                } 
            }
 
            return base.ConvertTo(context, culture, value, destinationType); 
        }
 
        /// 
        ///    Gets a collection of properties for
        ///       the type of array specified by the value parameter using the specified context and
        ///       attributes. 
        /// 
        public override PropertyDescriptorCollection GetProperties(ITypeDescriptorContext context, object value, Attribute[] attributes) { 
            //return new PropertyDescriptorCollection(null); 
            return null;
        } 

        /// 
        ///    Gets a value indicating whether this object
        ///       supports properties. 
        /// 
        public override bool GetPropertiesSupported(ITypeDescriptorContext context) { 
            return false; 
        }
 

    }
}
 

// File provided for Reference Use Only by Microsoft Corporation (c) 2007.
                        

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