Ejemplo n.º 1
0
        public JsExpression TryTranslateCall(LazyTranslatedExpression context, LazyTranslatedExpression[] arguments, MethodInfo method)
        {
            // Enum has totally strange behavior in reflection:
            // method.DeclaringType.IsEnum == false
            // method != typeof(Enum).GetMethod("ToString", Array.Empty<Type>())

            if (method?.DeclaringType == typeof(Enum) && method.Name == "ToString" && method.GetParameters().Length == 0)
            {
                return(context.JsExpression());
            }
            else
            {
                return(null);
            }
        }
Ejemplo n.º 2
0
 public JsExpression TryTranslateCall(LazyTranslatedExpression context, LazyTranslatedExpression[] arguments, MethodInfo method)
 {
     return(new JsInvocationExpression(
                new JsInvocationExpression(new JsIdentifierExpression("dotvvm").Member("globalize").Member("parseDotvvmDate"), context.JsExpression())
                .Member("getDayOfYear")
                ));
 }
Ejemplo n.º 3
0
        public JsExpression TryTranslateCall(LazyTranslatedExpression context, LazyTranslatedExpression[] arguments, MethodInfo method)
        {
            var tmp = new JsTemporaryVariableParameter();

            return(new JsBinaryExpression(
                       new JsAssignmentExpression(new JsSymbolicParameter(tmp), new JsInvocationExpression(new JsIdentifierExpression("dotvvm").Member("globalize").Member("parseDotvvmDate"), context.JsExpression())),
                       BinaryOperatorType.Sequence,
                       new JsNewExpression("Date",
                                           new JsInvocationExpression(new JsMemberAccessExpression(new JsSymbolicParameter(tmp), "getFullYear")),
                                           new JsInvocationExpression(new JsMemberAccessExpression(new JsSymbolicParameter(tmp), "getMonth")),
                                           new JsBinaryExpression(new JsInvocationExpression(new JsMemberAccessExpression(new JsSymbolicParameter(tmp), "getDate")), BinaryOperatorType.Plus, arguments[0].JsExpression()),
                                           new JsInvocationExpression(new JsMemberAccessExpression(new JsSymbolicParameter(tmp), "getHours")),
                                           new JsInvocationExpression(new JsMemberAccessExpression(new JsSymbolicParameter(tmp), "getMinutes")),
                                           new JsInvocationExpression(new JsMemberAccessExpression(new JsSymbolicParameter(tmp), "getSeconds")),
                                           new JsInvocationExpression(new JsMemberAccessExpression(new JsSymbolicParameter(tmp), "getMilliseconds"))
                                           )
                       ));
        }