// 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;
using System.Collections.Generic;
using System.IO;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.AspNetCore.Mvc.Razor;
using Microsoft.AspNetCore.Mvc.Rendering;
using Microsoft.AspNetCore.Mvc.ViewFeatures;
using Microsoft.AspNetCore.Mvc.ViewFeatures.Internal;
namespace Microsoft.AspNetCore.Mvc.RazorPages
{
///
/// The context associated with the current request for a Razor page.
///
public class PageContext : ViewContext
{
private CompiledPageActionDescriptor _actionDescriptor;
private Page _page;
private IList _valueProviderFactories;
///
/// Creates an empty .
///
///
/// The default constructor is provided for unit test purposes only.
///
public PageContext()
{
}
///
/// Initializes a new instance of .
///
/// The .
/// The .
/// The .
/// The to apply to this instance.
public PageContext(
ActionContext actionContext,
ViewDataDictionary viewData,
ITempDataDictionary tempDataDictionary,
HtmlHelperOptions htmlHelperOptions)
: base(actionContext, NullView.Instance, viewData, tempDataDictionary, TextWriter.Null, htmlHelperOptions)
{
}
///
/// Gets or sets the .
///
public new CompiledPageActionDescriptor ActionDescriptor
{
get
{
return _actionDescriptor;
}
set
{
_actionDescriptor = value;
base.ActionDescriptor = value;
}
}
public Page Page
{
get { return _page; }
set
{
if (value == null)
{
throw new ArgumentNullException(nameof(value));
}
_page = value;
}
}
///
/// Gets or sets the applicable _PageStart instances.
///
public IReadOnlyList PageStarts { get; set; }
///
/// 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;
}
}
}
}