AlphabeticalEnumConverter.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ Net / Net / 3.5.50727.3053 / DEVDIV / depot / DevDiv / releases / whidbey / netfxsp / ndp / fx / src / Services / Monitoring / system / Diagnosticts / AlphabeticalEnumConverter.cs / 1 / AlphabeticalEnumConverter.cs

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

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

 
    /// 
    ///  
    ///     
    ///       Provides a type converter to
    ///       convert ???? objects to and from various other representations. 
    ///    
    /// 
    internal class AlphabeticalEnumConverter : EnumConverter {
 
        public AlphabeticalEnumConverter(Type type) : base(type) {
        } 
 
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) {
            if (Values == null) { 
                Array objValues = Enum.GetValues(EnumType);
                //IComparer comparer = Comparer;
                object[] names = new object[objValues.Length];
                for (int i = 0; i < names.Length; i++) 
                    names[i] = ConvertTo(context, null, objValues.GetValue(i), typeof(string));
                Array.Sort(names, objValues, 0, objValues.Length, System.Collections.Comparer.Default); 
                Values = new StandardValuesCollection(objValues); 
            }
            return Values; 
        }

    }
 
}

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

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

 
    /// 
    ///  
    ///     
    ///       Provides a type converter to
    ///       convert ???? objects to and from various other representations. 
    ///    
    /// 
    internal class AlphabeticalEnumConverter : EnumConverter {
 
        public AlphabeticalEnumConverter(Type type) : base(type) {
        } 
 
        public override StandardValuesCollection GetStandardValues(ITypeDescriptorContext context) {
            if (Values == null) { 
                Array objValues = Enum.GetValues(EnumType);
                //IComparer comparer = Comparer;
                object[] names = new object[objValues.Length];
                for (int i = 0; i < names.Length; i++) 
                    names[i] = ConvertTo(context, null, objValues.GetValue(i), typeof(string));
                Array.Sort(names, objValues, 0, objValues.Length, System.Collections.Comparer.Default); 
                Values = new StandardValuesCollection(objValues); 
            }
            return Values; 
        }

    }
 
}

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