// 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.Diagnostics;
using Microsoft.AspNetCore.Mvc.Abstractions;
namespace Microsoft.AspNetCore.Mvc.RazorPages
{
[DebuggerDisplay(nameof(DebuggerDisplayString))]
public class PageActionDescriptor : ActionDescriptor
{
///
/// Initializes a new instance of .
///
public PageActionDescriptor()
{
}
///
/// A copy constructor for .
///
/// The to copy from.
public PageActionDescriptor(PageActionDescriptor other)
{
if (other == null)
{
throw new ArgumentNullException(nameof(other));
}
RelativePath = other.RelativePath;
ViewEnginePath = other.ViewEnginePath;
AreaName = other.AreaName;
}
///
/// Gets or sets the application root relative path for the page.
///
public string RelativePath { get; set; }
///
/// Gets or sets the path relative to the base path for page discovery.
///
/// This value is the path of the file without extension, relative to the pages root directory.
/// e.g. the for the file /Pages/Catalog/Antiques.cshtml is /Catalog/Antiques
///
///
/// In an area, this value is the path of the file without extension, relative to the pages root directory for the specified area.
/// e.g. the for the file Areas/Identity/Pages/Manage/Accounts.cshtml, is /Manage/Accounts.
///
///
public string ViewEnginePath { get; set; }
///
/// Gets or sets the area name for this page.
/// This value will be null for non-area pages.
///
public string AreaName { get; set; }
///
public override string DisplayName
{
get
{
if (base.DisplayName == null && ViewEnginePath != null)
{
base.DisplayName = ViewEnginePath;
}
return base.DisplayName;
}
set
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}
base.DisplayName = value;
}
}
private string DebuggerDisplayString() => $"{{ViewEnginePath = {nameof(ViewEnginePath)}, RelativePath = {nameof(RelativePath)}}}";
}
}