1
/* ****************************************************************************
3 * Copyright (c) Microsoft Corporation. All rights reserved.
5 * This software is subject to the Microsoft Public License (Ms-PL).
6 * A copy of the license can be found in the license.htm file included
7 * in this distribution.
9 * You must not remove this notice, or any other, from this software.
11 * ***************************************************************************/
13 namespace System
.Web
.Mvc
{
15 using System
.Globalization
;
16 using System
.Web
.Mvc
.Resources
;
18 public class ViewDataDictionary
<TModel
> : ViewDataDictionary where TModel
: class {
19 public ViewDataDictionary() :
23 public ViewDataDictionary(TModel model
) :
27 public ViewDataDictionary(ViewDataDictionary viewDataDictionary
) :
28 base(viewDataDictionary
) {
31 public new TModel Model
{
33 return (TModel
)base.Model
;
40 protected override void SetModel(object value) {
41 TModel model
= value as TModel
;
43 // If there was a value but the cast failed, throw an exception
44 if ((value != null) && (model
== null)) {
45 throw new InvalidOperationException(
46 String
.Format(CultureInfo
.CurrentUICulture
,
47 MvcResources
.ViewDataDictionary_WrongTModelType
, value.GetType(), typeof(TModel
)));