GenericNameHandler.cs source code in C# .NET

Source code for the .NET framework in C#

                        

Code:

/ DotNET / DotNET / 8.0 / untmp / whidbey / REDBITS / ndp / fx / src / Designer / System / data / design / GenericNameHandler.cs / 2 / GenericNameHandler.cs

                            //------------------------------------------------------------------------------ 
// 
//    Copyright (c) Microsoft Corporation. All Rights Reserved.
//    Information Contained Herein is Proprietary and Confidential.
//  
//-----------------------------------------------------------------------------
 
namespace System.Data.Design { 

    using System; 
    using System.Collections;
    using System.Globalization;
    using System.CodeDom.Compiler;
 

    internal sealed class GenericNameHandler { 
        private MemberNameValidator validator = null; 

        private Hashtable names = null; 

        internal GenericNameHandler(ICollection initialNameSet, CodeDomProvider codeProvider) {
            validator = new MemberNameValidator(initialNameSet, codeProvider, true /*languageCaseInsensitive*/);
            names = new Hashtable(StringComparer.Ordinal); 
        }
 
        internal string AddParameterNameToList(string originalName, string parameterPrefix) { 
            if (originalName == null) {
                throw new ArgumentNullException("originalName"); 
            }

            string noPrefixOriginalName = originalName;
            if (!StringUtil.Empty(parameterPrefix)) { 
                if (originalName.StartsWith(parameterPrefix, StringComparison.Ordinal)) {
                    noPrefixOriginalName = originalName.Substring(parameterPrefix.Length); 
                } 
            }
 
            string validatedName = validator.GetNewMemberName(noPrefixOriginalName);
            names.Add(originalName, validatedName);

            return validatedName; 
        }
 
        internal string AddNameToList(string originalName) { 
            if(originalName == null) {
                throw new InternalException("Parameter originalName should not be null."); 
            }

            string validatedName = validator.GetNewMemberName(originalName);
            names.Add(originalName, validatedName); 

            return validatedName; 
        } 

        internal string GetNameFromList(string originalName) { 
            if(originalName == null) {
                throw new InternalException("Parameter originalName should not be null.");
            }
 
            return (string) names[originalName];
        } 
    } 
}

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