Beispiel #1
0
        /// <summary>
        /// <para>Removes an application (And stops it if necessary).</para>
        /// </summary>
        public Task <VostokApplicationRunResult> RemoveApplicationAsync(VostokMultiHostApplicationIdentifier identifier)
        {
            if (applications.TryRemove(identifier, out var app))
            {
                return(app.StopAsync());
            }

            throw new KeyNotFoundException($"VostokMultiHost doesn't contain {identifier}.");
        }
Beispiel #2
0
 public VostokMultiHostApplicationSettings([NotNull] IVostokApplication application, [NotNull] VostokMultiHostApplicationIdentifier identifier, VostokHostingEnvironmentSetup environmentSetup = null)
 {
     Application      = application ?? throw new ArgumentNullException(nameof(application));
     Identifier       = identifier ?? throw new ArgumentNullException(nameof(identifier));
     EnvironmentSetup = environmentSetup ?? (builder => {});
 }
Beispiel #3
0
 public IVostokMultiHostApplication GetApplication(VostokMultiHostApplicationIdentifier identifier)
 => applications.TryGetValue(identifier, out var app) ? app : null;
        /// <summary>
        /// Stops provided application if it was added before.
        /// <see cref="VostokMultiHost"/> should be running to perform this operation.
        /// </summary>
        public static Task <VostokApplicationRunResult> StopApplicationAsync(this VostokMultiHost host, VostokMultiHostApplicationIdentifier identifier)
        {
            var application = host.GetApplication(identifier);

            if (application == null)
            {
                throw new InvalidOperationException($"{identifier} doesn't exist.");
            }

            return(application.StopAsync());
        }