|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Reflection;
using Signum.Utilities.Reflection;
using Signum.Entities;
using Signum.Web.Properties;
using Signum.Utilities.ExpressionTrees;
using Signum.Utilities;
using System.Web.Mvc;
using System.Web.Mvc.Html;
namespace Signum.Web
{
public static class TypeContextHelper
{
public static TypeContext<T> TypeContext<T>(this HtmlHelper helper) where T : ModifiableEntity
{
TypeContext<T> tc = helper.ViewData.Model as TypeContext<T>;
if (tc != null)
return tc;
T element = helper.ViewData.Model as T;
if (element == null)
throw new InvalidCastException("Impossible to convert object {0} from {1} to {2}".Formato(
helper.ViewData.Model,
helper.ViewData.Model.GetType().TypeName(),
typeof(TypeContext<T>).TypeName()));
return new TypeContext<T>(element, null);
}
public static MvcHtmlString NormalPageHeader(this HtmlHelper helper)
{
return helper.HiddenRuntimeInfo((TypeContext)helper.ViewData.Model);
}
public static MvcHtmlString PopupHeader(this HtmlHelper helper)
{
if (helper.ViewData.ContainsKey(ViewDataKeys.WriteSFInfo))
{
var entityInfo = helper.HiddenRuntimeInfo((TypeContext)helper.ViewData.Model);
helper.ViewData.Remove(ViewDataKeys.WriteSFInfo);
return entityInfo;
}
return null;
}
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
I'm Computer Scientist, one of the founders of Signum Software, and the lead developer behind Signum Framework.
www.signumframework.com
I love programming in C#, Linq, Compilers, Algorithms, Functional Programming, Computer Graphics, Maths...