예제 #1
0
        private static T GetCamelCaseModelObject <T>(T modelObject, string database, GenerationSettings settings)
            where T : BaseTable, IMetaData
        {
            bool   isCamelCaseName   = settings.IsCamelCaseName;
            bool   isDynamicLanguage = ConfigManager.SettingsSection.Languages[settings.Language].IsDynamic;
            string languageAlias     = ConfigManager.SettingsSection.Languages[settings.Language].Alias;

            if (!isCamelCaseName && isDynamicLanguage)
            {
                return(modelObject);
            }

            ITypeMapper typeMapper = null;

            if (!isDynamicLanguage)
            {
                typeMapper = TypeMapperFactory.Creator();
            }
            string typeMappingDatabase = ConfigManager.SettingsSection.Databases[database].TypeMapping;

            foreach (var column in modelObject.Columns.Values)
            {
                if (isCamelCaseName)
                {
                    column.Name = column.OriginalName.CamelCaseName();
                }
                if (typeMapper != null)
                {
                    LanguageType langType = typeMapper.GetLanguageType(typeMappingDatabase, languageAlias, column.DataType);
                    if (langType == null)
                    {
                        continue;
                    }
                    column.LanguageType         = langType.TypeName;
                    column.LanguageDefaultValue = string.IsNullOrEmpty(column.DefaultValue) ? langType.DefaultValue : column.DefaultValue;
                    column.LanguageTypeAlias    = langType.Alias;
                }
            }

            return(modelObject);
        }