/// <summary>
        /// Add a type-definition for mappings.
        /// </summary>
        /// <typeparam name="TDef">The peristent type.</typeparam>
        /// <param name="configuration">The <see cref="Configuration"/> where add the type-definition.</param>
        /// <param name="typeDefConfiguration">The custom configuration action.</param>
        /// <returns>The <see cref="Configuration"/>.</returns>
        /// <remarks>
        /// <para>
        /// <list type="bullet">
        /// <listheader>
        /// <description>Depending on where you will use the type-definition in the mapping the
        ///  <typeparamref name="TDef"/> can be :
        /// </description>
        ///</listheader>
        ///<item>
        ///    <term><see cref="NHibernate.UserTypes.IUserType"/></term>
        ///</item>
        ///<item>
        ///    <term><see cref="NHibernate.UserTypes.IUserCollectionType"/></term>
        ///</item>
        ///<item>
        ///    <term><see cref="NHibernate.UserTypes.IUserVersionType"/></term>
        ///</item>
        ///<item>
        ///    <term><see cref="NHibernate.Id.IPersistentIdentifierGenerator"/> </term>
        ///</item>
        ///</list>
        /// </para>
        /// </remarks>
        public static Configuration TypeDefinition <TDef>(this Configuration configuration, Action <ITypeDefConfigurationProperties> typeDefConfiguration)
            where TDef : class
        {
            if (typeDefConfiguration == null)
            {
                return(configuration);
            }
            var tdConfiguration = new TypeDefConfigurationProperties <TDef>();

            typeDefConfiguration(tdConfiguration);
            if (string.IsNullOrEmpty(tdConfiguration.Alias))
            {
                return(configuration);
            }
            var mappings = GetMappings(configuration);

            mappings.AddTypeDef(tdConfiguration.Alias, typeof(TDef).AssemblyQualifiedName, tdConfiguration.Properties.ToTypeParameters());
            return(configuration);
        }
Example #2
0
        public static Configuration TypeDefinition <TDef>(this Configuration configuration, Action <ITypeDefConfigurationProperties> typeDefConfiguration)
            where TDef : class
        {
            if (typeDefConfiguration == null)
            {
                return(configuration);
            }
            var tdConfiguration = TypeDefConfigurationProperties.Create <TDef>();

            typeDefConfiguration(tdConfiguration);
            if (string.IsNullOrEmpty(tdConfiguration.Alias))
            {
                return(configuration);
            }
            var mappings = configuration.CreateMappings();

            mappings.LazyDialect = new Lazy <Dialect.Dialect>(() => Dialect.Dialect.GetDialect(configuration.Properties));
            mappings.AddTypeDef(tdConfiguration.Alias, typeof(TDef).AssemblyQualifiedName, tdConfiguration.Properties.ToTypeParameters());
            return(configuration);
        }