// 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.Collections.Generic;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
namespace Microsoft.AspNetCore.Mvc.RazorPages
{
///
/// The context associated with the current request for a Razor page.
///
public class PageContext : ActionContext
{
private CompiledPageActionDescriptor _actionDescriptor;
private IList _valueProviderFactories;
private ViewDataDictionary _viewData;
private IList> _viewStartFactories;
///
/// Creates an empty .
///
///
/// The default constructor is provided for unit test purposes only.
///
public PageContext()
{
}
///
/// Initializes a new instance of .
///
/// The .
public PageContext(ActionContext actionContext)
: base(actionContext)
{
}
///
/// Gets or sets the .
///
public virtual new CompiledPageActionDescriptor ActionDescriptor
{
get
{
return _actionDescriptor;
}
set
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}
_actionDescriptor = value;
base.ActionDescriptor = value;
}
}
///
/// Gets or sets the list of instances for the current request.
///
public virtual IList ValueProviderFactories
{
get
{
if (_valueProviderFactories == null)
{
_valueProviderFactories = new List();
}
return _valueProviderFactories;
}
set
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}
_valueProviderFactories = value;
}
}
///
/// Gets or sets .
///
public virtual ViewDataDictionary ViewData
{
get
{
return _viewData;
}
set
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}
_viewData = value;
}
}
///
/// Gets or sets the applicable _ViewStart instances.
///
public virtual IList> ViewStartFactories
{
get
{
return _viewStartFactories;
}
set
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}
_viewStartFactories = value;
}
}
}
}