// 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;
namespace Microsoft.AspNetCore.Blazor.Layouts
{
///
/// Indicates that the associated component type uses a specified layout.
///
[AttributeUsage(AttributeTargets.Class, AllowMultiple = false, Inherited = true)]
public class LayoutAttribute : Attribute
{
///
/// The type of the layout. The type always implements .
///
public Type LayoutType { get; private set; }
///
/// Constructs an instance of .
///
/// The type of the layout. This must implement .
public LayoutAttribute(Type layoutType)
{
LayoutType = layoutType ?? throw new ArgumentNullException(nameof(layoutType));
if (!typeof(ILayoutComponent).IsAssignableFrom(layoutType))
{
throw new ArgumentException($"Invalid layout type: {layoutType.FullName} " +
$"does not implement {typeof(ILayoutComponent).FullName}.");
}
}
}
}