// Copyright (c) .NET Foundation. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System; using System.Reflection; namespace Microsoft.AspNetCore.Hosting { /// /// Marker attribute indicating an implementation of that will be loaded and executed when building an . /// [AttributeUsage(AttributeTargets.Assembly, Inherited = false, AllowMultiple = true)] public sealed class HostingStartupAttribute : Attribute { /// /// Constructs the with the specified type. /// /// A type that implements . public HostingStartupAttribute(Type hostingStartupType) { if (hostingStartupType == null) { throw new ArgumentNullException(nameof(hostingStartupType)); } if (!typeof(IHostingStartup).GetTypeInfo().IsAssignableFrom(hostingStartupType.GetTypeInfo())) { throw new ArgumentException($@"""{hostingStartupType}"" does not implement {typeof(IHostingStartup)}.", nameof(hostingStartupType)); } HostingStartupType = hostingStartupType; } /// /// The implementation of that should be loaded when /// starting an application. /// public Type HostingStartupType { get; } } }