<commit_before>﻿namespace XmlSchemaClassGenerator
{
    using System.Xml;

    /// <summary>
    /// Provides options to customize member names
    /// </summary>
    public class NamingProvider
        : INamingProvider
    {
        private readonly NamingScheme _namingScheme;

        /// <summary>
        /// Initializes a new instance of the <see cref="NamingProvider"/> class.
        /// </summary>
        /// <param name="namingScheme">The naming scheme.</param>
        public NamingProvider(NamingScheme namingScheme)
        {
            _namingScheme = namingScheme;
        }

        /// <summary>
        /// Creates a name for a property from an attribute name
        /// </summary>
        /// <param name="typeModelName">Name of the typeModel</param>
        /// <param name="attributeName">Attribute name</param>
        /// <returns>Name of the property</returns>
        public virtual string PropertyNameFromAttribute(string typeModelName, string attributeName)
        {
            return PropertyNameFromElement(typeModelName, attributeName);
        }

        /// <summary>
        /// Creates a name for a property from an element name
        /// </summary>
        /// <param name="typeModelName">Name of the typeModel</param>
        /// <param name="elementName">Element name</param>
        /// <returns>Name of the property</returns>
        public virtual string PropertyNameFromElement(string typeModelName, string elementName)
        {
            return typeModelName.ToTitleCase(_namingScheme) + elementName.ToTitleCase(_namingScheme);
        }

        /// <summary>
        /// Creates a name for an enum member based on a value
        /// </summary>
        /// <param name="enumName">Name of the enum</param>
        /// <param name="value">Value name</param>
        /// <returns>Name of the enum member</returns>
        public virtual string EnumMemberNameFromValue(string enumName, string value)
        {
            return value.ToTitleCase(_namingScheme).ToNormalizedEnumName();
        }

        /// <summary>
        /// Define the name to be used when a ComplexType is found in the XSD.
        /// </summary>
        /// <param name="qualifiedName">The name as defined in the XSD if present.</param>
        /// <returns>A string with a valid C# identifier name.</returns>
        public string ComplexTypeNameFromQualifiedName(XmlQualifiedName qualifiedName)
        {
            return qualifiedName.Name.ToTitleCase(NamingScheme.PascalCase);
        }

        /// <summary>
        /// Define the name to be used when a AttributeGroup is found in the XSD.
        /// </summary>
        /// <param name="qualifiedName">The name as defined in the XSD if present.</param>
        /// <returns>A string with a valid C# identifier name.</returns>
        public string AttributeGroupTypeNameFromQualifiedName(XmlQualifiedName qualifiedName)
        {
            return qualifiedName.Name.ToTitleCase(NamingScheme.PascalCase);
        }

        /// <summary>
        /// Define the name to be used when a GroupType is found in the XSD.
        /// </summary>
        /// <param name="qualifiedName">The name as defined in the XSD if present.</param>
        /// <returns>A string with a valid C# identifier name.</returns>
        public string GroupTypeNameFromQualifiedName(XmlQualifiedName qualifiedName)
        {
            return qualifiedName.Name.ToTitleCase(NamingScheme.PascalCase);
        }

        /// <summary>
        /// Define the name to be used when a SimpleType is found in the XSD.
        /// </summary>
        /// <param name="qualifiedName">The name as defined in the XSD if present.</param>
        /// <returns>A string with a valid C# identifier name.</returns>
        public string SimpleTypeNameFromQualifiedName(XmlQualifiedName qualifiedName)
        {
            return qualifiedName.Name.ToTitleCase(NamingScheme.PascalCase);
        }

        /// <summary>
        /// Define the name to be used for the root class.
        /// </summary>
        /// <param name="qualifiedName">The name as defined in the XSD if present.</param>
        /// <returns>A string with a valid C# identifier name.</returns>
        public string RootClassNameFromQualifiedName(XmlQualifiedName qualifiedName)
        {
            return qualifiedName.Name.ToTitleCase(NamingScheme.PascalCase);
        }

        /// <summary>
        /// Define the name to be used when an enum type is found in the XSD.
        /// </summary>
        /// <param name="qualifiedName">The name as defined in the XSD if present.</param>
        /// <returns>A string with a valid C# identifier name.</returns>
        public string EnumTypeNameFromQualifiedName(XmlQualifiedName qualifiedName)
        {
            return qualifiedName.Name.ToTitleCase(NamingScheme.PascalCase);
        }

        /// <summary>
        /// Define the name to be used when an attribute is found in the XSD.
        /// </summary>
        /// <param name="qualifiedName">The name as defined in the XSD if present.</param>
        /// <returns>A string with a valid C# identifier name.</returns>
        public string AttributeNameFromQualifiedName(XmlQualifiedName qualifiedName)
        {
            return qualifiedName.Name.ToTitleCase(NamingScheme.PascalCase);
        }

        /// <summary>
        /// Define the name of the C# class property from the element name in XSD.
        /// </summary>
        /// <param name="qualifiedName">The name as defined in the XSD if present.</param>
        /// <returns>A string with a valid C# identifier name.</returns>
        public string ElementNameFromQualifiedName(XmlQualifiedName qualifiedName)
        {
            return qualifiedName.Name.ToTitleCase(NamingScheme.PascalCase);
        }
    }
}<commit_msg>NamingProvider: Made functions virtual and grouped all common code into single virtual function.<commit_after>﻿namespace XmlSchemaClassGenerator
{
    using System.Xml;

    /// <summary>
    /// Provides options to customize member names
    /// </summary>
    public class NamingProvider
        : INamingProvider
    {
        private readonly NamingScheme _namingScheme;

        /// <summary>
        /// Initializes a new instance of the <see cref="NamingProvider"/> class.
        /// </summary>
        /// <param name="namingScheme">The naming scheme.</param>
        public NamingProvider(NamingScheme namingScheme)
        {
            _namingScheme = namingScheme;
        }

        /// <summary>
        /// Creates a name for a property from an attribute name
        /// </summary>
        /// <param name="typeModelName">Name of the typeModel</param>
        /// <param name="attributeName">Attribute name</param>
        /// <returns>Name of the property</returns>
        public virtual string PropertyNameFromAttribute(string typeModelName, string attributeName)
        {
            return PropertyNameFromElement(typeModelName, attributeName);
        }

        /// <summary>
        /// Creates a name for a property from an element name
        /// </summary>
        /// <param name="typeModelName">Name of the typeModel</param>
        /// <param name="elementName">Element name</param>
        /// <returns>Name of the property</returns>
        public virtual string PropertyNameFromElement(string typeModelName, string elementName)
        {
            return typeModelName.ToTitleCase(_namingScheme) + elementName.ToTitleCase(_namingScheme);
        }

        /// <summary>
        /// Creates a name for an enum member based on a value
        /// </summary>
        /// <param name="enumName">Name of the enum</param>
        /// <param name="value">Value name</param>
        /// <returns>Name of the enum member</returns>
        public virtual string EnumMemberNameFromValue(string enumName, string value)
        {
            return value.ToTitleCase(_namingScheme).ToNormalizedEnumName();
        }

        /// <summary>
        /// Define the name to be used when a ComplexType is found in the XSD.
        /// </summary>
        /// <param name="qualifiedName">The name as defined in the XSD if present.</param>
        /// <returns>A string with a valid C# identifier name.</returns>
        public virtual string ComplexTypeNameFromQualifiedName(XmlQualifiedName qualifiedName)
        {
            return QualifiedNameToTitleCase(qualifiedName);
        }

        /// <summary>
        /// Define the name to be used when a AttributeGroup is found in the XSD.
        /// </summary>
        /// <param name="qualifiedName">The name as defined in the XSD if present.</param>
        /// <returns>A string with a valid C# identifier name.</returns>
        public virtual string AttributeGroupTypeNameFromQualifiedName(XmlQualifiedName qualifiedName)
        {
            return QualifiedNameToTitleCase(qualifiedName);
        }

        /// <summary>
        /// Define the name to be used when a GroupType is found in the XSD.
        /// </summary>
        /// <param name="qualifiedName">The name as defined in the XSD if present.</param>
        /// <returns>A string with a valid C# identifier name.</returns>
        public virtual string GroupTypeNameFromQualifiedName(XmlQualifiedName qualifiedName)
        {
            return QualifiedNameToTitleCase(qualifiedName);
        }

        /// <summary>
        /// Define the name to be used when a SimpleType is found in the XSD.
        /// </summary>
        /// <param name="qualifiedName">The name as defined in the XSD if present.</param>
        /// <returns>A string with a valid C# identifier name.</returns>
        public virtual string SimpleTypeNameFromQualifiedName(XmlQualifiedName qualifiedName)
        {
            return QualifiedNameToTitleCase(qualifiedName);
        }

        /// <summary>
        /// Define the name to be used for the root class.
        /// </summary>
        /// <param name="qualifiedName">The name as defined in the XSD if present.</param>
        /// <returns>A string with a valid C# identifier name.</returns>
        public virtual string RootClassNameFromQualifiedName(XmlQualifiedName qualifiedName)
        {
            return QualifiedNameToTitleCase(qualifiedName);
        }

        /// <summary>
        /// Define the name to be used when an enum type is found in the XSD.
        /// </summary>
        /// <param name="qualifiedName">The name as defined in the XSD if present.</param>
        /// <returns>A string with a valid C# identifier name.</returns>
        public virtual string EnumTypeNameFromQualifiedName(XmlQualifiedName qualifiedName)
        {
            return QualifiedNameToTitleCase(qualifiedName);
        }

        /// <summary>
        /// Define the name to be used when an attribute is found in the XSD.
        /// </summary>
        /// <param name="qualifiedName">The name as defined in the XSD if present.</param>
        /// <returns>A string with a valid C# identifier name.</returns>
        public virtual string AttributeNameFromQualifiedName(XmlQualifiedName qualifiedName)
        {
            return QualifiedNameToTitleCase(qualifiedName);
        }

        /// <summary>
        /// Define the name of the C# class property from the element name in XSD.
        /// </summary>
        /// <param name="qualifiedName">The name as defined in the XSD if present.</param>
        /// <returns>A string with a valid C# identifier name.</returns>
        public virtual string ElementNameFromQualifiedName(XmlQualifiedName qualifiedName)
        {
            return QualifiedNameToTitleCase(qualifiedName);
        }

        /// <summary>
        /// Used internally to make the QualifiedName have the desired naming schema.
        /// </summary>
        /// <param name="qualifiedName">Not null element.</param>
        /// <returns>A string formatted as desired.</returns>
        protected virtual string QualifiedNameToTitleCase(XmlQualifiedName qualifiedName)
        {
            return qualifiedName.Name.ToTitleCase(_namingScheme);
        }
    }
}
{'fraction_non_alphanumeric': 0.10248986682107701, 'fraction_numerical': 0.0, 'mean_word_length': 2.1866104375329467, 'pattern_counts': {'":': 0, '<': 167, '<?xml version=': 0, '>': 167, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5438181', 'n_tokens_mistral': 3024, 'n_tokens_neox': 2948, 'n_words': 969}