コード例 #1
0
 public static bool TrySet(JavascriptDynamic.JavascriptFallback fallback, object value)
 {
     if (value.GetType() == typeof(JavascriptDynamic.JavascriptFallback))
     {
         var setValueFallback = (JavascriptDynamic.JavascriptFallback)value;
         fallback.RuntimeJavascript.SetJavascriptData(fallback.GetJavascriptCommand(), setValueFallback.GetJavascriptCommand());
     }
     else
     {
         fallback.RuntimeJavascript.SetJavascriptData(fallback.GetJavascriptCommand(), JavascriptArgumentUtils.Parse(value));
     }
     return(true);
 }
コード例 #2
0
        internal static object DoBinaryOperation(BinaryOperationBinder binder, JavascriptDynamic.JavascriptFallback fallback, object arg)
        {
            var    runtimeJs    = fallback.RuntimeJavascript;
            object firstObject  = runtimeJs.ExecuteJavascriptReturn(fallback.GetJavascriptCommand());
            object secondObject = runtimeJs.ExecuteJavascriptReturn(arg.ToString());

            if (firstObject.GetType() == typeof(Int32))
            {
                firstObject = (Int64)firstObject;
            }
            if (secondObject.GetType() == typeof(Int32))
            {
                secondObject = (Int64)secondObject;
            }

            if (firstObject.GetType() == typeof(Int64) && secondObject.GetType() == typeof(Int64))
            {
                Int64 number1 = (Int64)firstObject;
                Int64 number2 = (Int64)secondObject;

                switch (binder.Operation)
                {
                case ExpressionType.Add:
                    return(number1 + number2);

                case ExpressionType.Multiply:
                    return(number1 * number2);

                case ExpressionType.Divide:
                    return(number1 / number2);

                case ExpressionType.Subtract:
                    return(number1 - number2);
                }
            }

            throw new Exception($"Invalid binary operation: {firstObject.GetType().Name} with {firstObject.GetType().Name}");
        }
コード例 #3
0
 public static object ToRaw(JavascriptDynamic.JavascriptFallback fallback, InvokeMemberBinder binder, object[] args)
 {
     return(fallback.GetJavascriptCommand());
 }
コード例 #4
0
 public static object ExecuteReturn(JavascriptDynamic.JavascriptFallback fallback, InvokeMemberBinder binder, object[] args)
 {
     return(fallback.RuntimeJavascript.ExecuteJavascriptReturn(fallback.GetJavascriptCommand()));
 }