public static SessionFactoryInfo GetFromAssemblyOf <T>(IPersistenceConfigurer configurer,
                                                               FluentNHibernatePersistenceBuilderOptions options = null)
        {
            options = options ?? new FluentNHibernatePersistenceBuilderOptions();
            var providerType = ProviderTypeHelper.InferProviderType(configurer);
            var derivedInfo  = PersistenceConfigurationHelper.GetDerivedConnectionInfo(configurer);

            if (derivedInfo == null)
            {
                throw new ArgumentException("Could not derive connection string info from configurer");
            }
            options.DefaultSchema = derivedInfo.DefaultSchema;
            Func <ConfigurationInfo> configFunc = () => new ConfigurationInfo(configurer, options, providerType);
            var keyInfo = new KeyInfo
            {
                ProviderType           = providerType,
                NameOrConnectionString = derivedInfo.ConnectionString,
                options      = options,
                TypeFullName = typeof(T).FullName
            };

            return(GetSessionFactoryInfo <T>(options, keyInfo, providerType, configFunc));
        }
示例#2
0
        public static SessionFactoryInfo GetFromAssemblies(List <Assembly> sourceAssemblies,
                                                           IPersistenceConfigurer configurer,
                                                           FluentNHibernatePersistenceBuilderOptions options = null)
        {
            options = options ?? new FluentNHibernatePersistenceBuilderOptions();
            var providerType = ProviderTypeHelper.InferProviderType(configurer);
            var derivedInfo  = PersistenceConfigurationHelper.GetDerivedConnectionInfo(configurer);

            if (derivedInfo == null)
            {
                throw new ArgumentException("Could not derive connection string info from configurer");
            }
            options.DefaultSchema = derivedInfo.DefaultSchema;
            Func <ConfigurationInfo> configFunc = () => new ConfigurationInfo(configurer, options, providerType);
            var keyInfo = new KeyInfo
            {
                ProviderType           = providerType,
                NameOrConnectionString = derivedInfo.ConnectionString,
                Options       = options,
                AssemblyNames = string.Join(",", sourceAssemblies.Distinct().OrderBy(i => i.FullName))
            };

            return(GetSessionFactoryInfo(sourceAssemblies, options, keyInfo, providerType, configFunc));
        }