Пример #1
0
        public static StorageNode BuildNode(Domain parentDomain, NodeConfiguration nodeConfiguration)
        {
            ArgumentValidator.EnsureArgumentNotNull(parentDomain, "parentDomain");
            ArgumentValidator.EnsureArgumentNotNull(nodeConfiguration, "nodeConfiguration");

            nodeConfiguration.Validate(parentDomain.Configuration);
            if (!nodeConfiguration.IsLocked)
            {
                nodeConfiguration.Lock();
            }

            var context = new UpgradeContext(parentDomain, nodeConfiguration);

            using (context.Activate())
                using (context.Services) {
                    new UpgradingDomainBuilder(context).Run();
                    return(context.StorageNode);
                }
        }
Пример #2
0
        public static async Task <StorageNode> BuildNodeAsync(
            Domain parentDomain, NodeConfiguration nodeConfiguration, CancellationToken token)
        {
            ArgumentValidator.EnsureArgumentNotNull(parentDomain, nameof(parentDomain));
            ArgumentValidator.EnsureArgumentNotNull(nodeConfiguration, nameof(nodeConfiguration));

            nodeConfiguration.Validate(parentDomain.Configuration);
            if (!nodeConfiguration.IsLocked)
            {
                nodeConfiguration.Lock();
            }

            var context = new UpgradeContext(parentDomain, nodeConfiguration);

            using (context.Activate())
                using (context.Services) {
                    await new UpgradingDomainBuilder(context).RunAsync(token).ConfigureAwait(false);
                    return(context.StorageNode);
                }
        }