public static RenderingScope <I> Transform <M, S, I, D>(this IHtmlHelper <M> h, Expression <Func <M, S> > expression, IBindingTransformation <S, I, D> transform)
        {
            if (expression == null)
            {
                throw new ArgumentNullException(nameof(expression));
            }
            if (transform == null)
            {
                throw new ArgumentNullException(nameof(transform));
            }
            transform.Context = h.ViewContext.HttpContext;
            S model = default(S);

            try
            {
                model = expression.Compile().Invoke(h.ViewData.Model);
            }
            catch { }

            var pres   = transform.Transform(model);
            var prefix = TransformationsRegister.GetPrefix(transform.GetType());

            prefix = combinePrefixes(ExpressionHelper.GetExpressionText(expression), prefix);
            return(Scope <I>(h, prefix, pres));
        }
Ejemplo n.º 2
0
 public static void Registration()
 {
     TransformationsRegister.Add(typeof(JsonTransformation <>));
     TransformationsRegister.Add(typeof(EncryptedJsonTransformation <>));
 }