StringValueConverter.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ FX-1434 / FX-1434 / 1.0 / untmp / whidbey / REDBITS / ndp / fx / src / Services / Monitoring / system / Diagnosticts / Design / StringValueConverter.cs / 1 / StringValueConverter.cs

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

 namespace System.Diagnostics.Design { 
    using System; 
    using System.ComponentModel;
    using System.ComponentModel.Design; 
    using System.Globalization;

    /// 
    internal class StringValueConverter : TypeConverter { 

        ///  
        public override bool CanConvertFrom(ITypeDescriptorContext context, Type sourceType) { 
            if (sourceType == typeof(string)) {
                return true; 
            }
            return base.CanConvertFrom(context, sourceType);
        }
 
        /// 
        public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { 
            if (value is string) { 
                string text = ((string)value).Trim();
 
                if (text == String.Empty)
                    text = null;

                return text; 
            }
 
            return base.ConvertFrom(context, culture, value); 
        }
    } 
}

// 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