/// <summary> /// Converts the element to a native configuration object it corresponds to - /// i.e. to a <see cref="SessionConfiguration"/> object. /// </summary> /// <returns>The result of conversion.</returns> public SessionConfiguration ToNative() { // Minor hack: // We should not require user to specify provider name. // We actually know it when opening new session. // However, we do not know it in this method // We are going easy way and substituting a fake provider. // SQL SessionHandler is aware of this and always uses correct provider. var connectionInfo = ConnectionInfoParser.GetConnectionInfo(CurrentConfiguration, ConnectionUrl, "_dummy_", ConnectionString); var result = new SessionConfiguration(Name) { UserName = UserName, Password = Password, CacheSize = CacheSize, BatchSize = BatchSize, CacheType = (SessionCacheType)Enum.Parse(typeof(SessionCacheType), CacheType, true), Options = (SessionOptions)Enum.Parse(typeof(SessionOptions), Options, true), DefaultIsolationLevel = (IsolationLevel)Enum.Parse(typeof(IsolationLevel), DefaultIsolationLevel, true), ReaderPreloading = (ReaderPreloadingPolicy)Enum.Parse(typeof(ReaderPreloadingPolicy), ReaderPreloading, true), ServiceContainerType = Type.GetType(ServiceContainerType), EntityChangeRegistrySize = EntityChangeRegistrySize, DefaultCommandTimeout = DefaultCommandTimeout, ConnectionInfo = connectionInfo, }; return(result); }
/// <summary> /// Converts the element to a native configuration object it corresponds to - /// i.e. to a <see cref="DomainConfiguration"/> object. /// </summary> /// <returns>The result of conversion.</returns> public DomainConfiguration ToNative() { var config = new DomainConfiguration { Name = Name, ConnectionInfo = ConnectionInfoParser.GetConnectionInfo(CurrentConfiguration, ConnectionUrl, Provider, ConnectionString), NamingConvention = NamingConvention.ToNative(), KeyCacheSize = KeyCacheSize, KeyGeneratorCacheSize = KeyGeneratorCacheSize, QueryCacheSize = QueryCacheSize, RecordSetMappingCacheSize = RecordSetMappingCacheSize, DefaultSchema = DefaultSchema, DefaultDatabase = DefaultDatabase, UpgradeMode = ParseEnum <DomainUpgradeMode>(UpgradeMode), ForeignKeyMode = ParseEnum <ForeignKeyMode>(ForeignKeyMode), SchemaSyncExceptionFormat = ParseEnum <SchemaSyncExceptionFormat>(SchemaSyncExceptionFormat), Options = ParseEnum <DomainOptions>(Options), ServiceContainerType = ServiceContainerType.IsNullOrEmpty() ? null : Type.GetType(ServiceContainerType), IncludeSqlInExceptions = IncludeSqlInExceptions, BuildInParallel = BuildInParallel, AllowCyclicDatabaseDependencies = AllowCyclicDatabaseDependencies, ForcedServerVersion = ForcedServerVersion, Collation = Collation, ConnectionInitializationSql = ConnectionInitializationSql, MultidatabaseKeys = MultidatabaseKeys, ShareStorageSchemaOverNodes = ShareStorageSchemaOverNodes, EnsureConnectionIsAlive = EnsureConnectionIsAlive, FullTextChangeTrackingMode = ParseEnum <FullTextChangeTrackingMode>(FullTextChangeTrackingMode), VersioningConvention = VersioningConvention.ToNative() }; foreach (var element in Types) { config.Types.Register(element.ToNative()); } foreach (var element in Sessions) { config.Sessions.Add(element.ToNative()); } foreach (var element in MappingRules) { config.MappingRules.Add(element.ToNative()); } foreach (var element in Databases) { config.Databases.Add(element.ToNative()); } foreach (var element in KeyGenerators) { config.KeyGenerators.Add(element.ToNative()); } foreach (var element in IgnoreRules) { config.IgnoreRules.Add(element.ToNative()); } return(config); }