/// <summary> /// Gets the naming strategy. /// </summary> /// <param name="componentMapping">The component mapping.</param> /// <returns>A <see cref="Orion.Framework.DataLayer.NH.Domain.IComponentNamingStrategy"/></returns> public static IComponentNamingStrategy GetNamingStrategy(this IComponentMapping componentMapping) { IComponentNamingStrategy componentNamingStrategy = null; var namingAttributes = componentMapping.Member.MemberInfo.GetCustomAttributes( typeof(ComponentNamingStrategyAttribute), false); if (namingAttributes.Count() > 0) { var namingAttribute = namingAttributes[0] as ComponentNamingStrategyAttribute; if (namingAttribute != null) { componentNamingStrategy = namingAttribute.ComponentNamingStrategy; } } var componentType = componentMapping.Member.PropertyType; if (componentNamingStrategy == null) { var classNamingAttributes = componentType.GetCustomAttributes( typeof(ComponentNamingStrategyAttribute), false); if (classNamingAttributes.Count() > 0) { var classNamingAttribute = classNamingAttributes[0] as ComponentNamingStrategyAttribute; if (classNamingAttribute != null) { componentNamingStrategy = classNamingAttribute.ComponentNamingStrategy; } } } return(componentNamingStrategy ?? new ComponentPropertyReplaceStrategy()); }
/// <summary> /// Gets the name of the column. /// </summary> /// <param name="componentNamingStrategy">The component naming strategy.</param> /// <param name="entityMember">The entity member.</param> /// <param name="componentMember">The component member.</param> /// <param name="shortNameIndicator">If set to <c>true</c> [short name indicator].</param> /// <returns>The column name.</returns> public static string GetColumnName( this IComponentNamingStrategy componentNamingStrategy, Member entityMember, Member componentMember, bool shortNameIndicator) { return(componentNamingStrategy.GetColumnName( entityMember.DeclaringType, entityMember.PropertyType, entityMember.Name, componentMember.DeclaringType, componentMember.PropertyType, componentMember.Name, shortNameIndicator)); }