Skip to content

Commit 5eec512

Browse files
committed
DomainConfiguration.Load() implemented
1 parent facc593 commit 5eec512

1 file changed

Lines changed: 20 additions & 3 deletions

File tree

Orm/Xtensive.Orm/Orm/Configuration/DomainConfiguration.cs

Lines changed: 20 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (C) 2007-2022 Xtensive LLC.
1+
// Copyright (C) 2007-2024 Xtensive LLC.
22
// This code is distributed under MIT license terms.
33
// See the License.txt file in the project root for more information.
44
// Created by: Dmitri Maximov
@@ -73,7 +73,7 @@ public class DomainConfiguration : ConfigurationBase
7373
public const bool DefaultShareStorageSchemaOverNodes = false;
7474

7575
/// <summary>
76-
/// Default <see cref="AllowCyclicDatabaseDependencies" /> value: <see langword="false" />
76+
/// Default <see cref="AllowCyclicDatabaseDependencies" /> value: <see langword="false" />.
7777
/// </summary>
7878
public const bool DefaultAllowCyclicDatabaseDependencies = false;
7979

@@ -881,8 +881,25 @@ private static DomainConfiguration LoadConfigurationFromSection(ConfigurationSec
881881
/// <exception cref="InvalidOperationException">The "domains" section is not found or domain with requested name is not found.</exception>
882882
public static DomainConfiguration Load(IConfigurationSection configurationSection, string name)
883883
{
884-
throw new NotImplementedException();
884+
var allDomainsSection = configurationSection.GetSection("Domains");
885+
if (allDomainsSection != null && allDomainsSection.GetChildren().Any()) {
886+
var domainSection = allDomainsSection.GetSection(name);
887+
if (domainSection.GetChildren().Any()) {
888+
var parseResult = new FromJsonToDomainConfigurationParser().Parse(domainSection);
889+
if (parseResult != null)
890+
return parseResult;
891+
}
892+
else if ((domainSection = allDomainsSection.GetSection($"Domain:{name}")).GetChildren().Any()) {
893+
var parseResult = new XmlDomainConfigParser().Parse(domainSection);
894+
if (parseResult != null)
895+
return parseResult;
896+
}
897+
}
898+
899+
throw new InvalidOperationException(string.Format(
900+
Strings.ExConfigurationForDomainIsNotFoundInApplicationConfigurationFile, name, sectionName));
885901
}
902+
886903
#endregion
887904

888905
// Constructors

0 commit comments

Comments
 (0)