// 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 Microsoft.AspNetCore.Mvc.ModelBinding; namespace Microsoft.AspNetCore.Mvc.ViewFeatures { public class ViewDataDictionary : ViewDataDictionary { /// /// Initializes a new instance of the class. /// /// /// For use when creating a for a new top-level scope. /// /// // References may not show up due to Type.GetConstructor() use in RazorPageActivator. public ViewDataDictionary( IModelMetadataProvider metadataProvider, ModelStateDictionary modelState) : base(metadataProvider, modelState, declaredModelType: typeof(TModel)) { } /// /// Initializes a new instance of the class based in part on an /// existing instance. /// /// /// /// For use when copying a instance and is known /// but should be copied from the existing instance e.g. when copying from a base /// instance to a instance. /// /// /// This constructor may throw if source.Model is non-null and incompatible with /// . Pass model: null to /// to ignore source.Model. /// /// /// // References may not show up due to Type.GetConstructor() use in RazorPageActivator. public ViewDataDictionary(ViewDataDictionary source) : base(source, declaredModelType: typeof(TModel)) { } /// /// Initializes a new instance of the class based in part on an /// existing instance. This constructor is careful to avoid exceptions /// may throw when is null. /// /// /// /// For use when copying a instance and and /// are known. /// /// /// This constructor may throw if is non-null and incompatible with /// . /// /// /// // Model parameter type is object to allow "model: null" calls even when TModel is a value type. A TModel // parameter would likely require IEquatable type restrictions to pass expected null value to the base // constructor. public ViewDataDictionary(ViewDataDictionary source, object model) : base(source, model, declaredModelType: typeof(TModel)) { } /// /// Initializes a new instance of the class. /// /// Internal for testing. /// internal ViewDataDictionary(IModelMetadataProvider metadataProvider) : base(metadataProvider, declaredModelType: typeof(TModel)) { } /// public new TModel Model { get { return (base.Model == null) ? default(TModel) : (TModel)base.Model; } set { base.Model = value; } } } }