• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# Hosting.JavaScriptValue类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中ChakraHost.Hosting.JavaScriptValue的典型用法代码示例。如果您正苦于以下问题:C# JavaScriptValue类的具体用法?C# JavaScriptValue怎么用?C# JavaScriptValue使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



JavaScriptValue类属于ChakraHost.Hosting命名空间,在下文中一共展示了JavaScriptValue类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: RunScript

        private static JavaScriptValue RunScript(JavaScriptValue callee, bool isConstructCall, JavaScriptValue[] arguments, ushort argumentCount, IntPtr callbackData)
        {
            if (argumentCount < 2)
            {
                ThrowException("not enough arguments");
                return JavaScriptValue.Invalid;
            }

            //
            // Convert filename.
            //

            string filename = arguments[1].ToString();

            //
            // Load the script from the disk.
            //

            string script = File.ReadAllText(filename);
            if (string.IsNullOrEmpty(script))
            {
                ThrowException("invalid script");
                return JavaScriptValue.Invalid;
            }

            //
            // Run the script.
            //

            return JavaScriptContext.RunScript(script, currentSourceContext++, filename);
        }
开发者ID:nagaozen,项目名称:chakra-host,代码行数:31,代码来源:Program.cs


示例2: init

        public string init()
        {
            JavaScriptContext context;

            if (Native.JsCreateRuntime(JavaScriptRuntimeAttributes.None, null, out runtime) != JavaScriptErrorCode.NoError)
                return "failed to create runtime.";

            if (Native.JsCreateContext(runtime, out context) != JavaScriptErrorCode.NoError)
                return "failed to create execution context.";

            if (Native.JsSetCurrentContext(context) != JavaScriptErrorCode.NoError)
                return "failed to set current context.";

            // ES6 Promise callback
            JavaScriptPromiseContinuationCallback promiseContinuationCallback = delegate (JavaScriptValue task, IntPtr callbackState)
            {
                promiseCallback = task;
            };

            if (Native.JsSetPromiseContinuationCallback(promiseContinuationCallback, IntPtr.Zero) != JavaScriptErrorCode.NoError)
                return "failed to setup callback for ES6 Promise";

            if (Native.JsProjectWinRTNamespace("Windows") != JavaScriptErrorCode.NoError)
                return "failed to project windows namespace.";

            if (Native.JsStartDebugging() != JavaScriptErrorCode.NoError)
                return "failed to start debugging.";

            return "NoError";
        }
开发者ID:KennyLisc,项目名称:Chakra-Samples,代码行数:30,代码来源:ChakraHost.cs


示例3: Echo

        private static JavaScriptValue Echo(JavaScriptValue callee, bool isConstructCall, JavaScriptValue[] arguments, ushort argumentCount, IntPtr callbackData)
        {
            for (uint index = 1; index < argumentCount; index++)
            {
                if (index > 1)
                {
                    Console.Write(" ");
                }

                Console.Write(arguments[index].ConvertToString().ToString());
            }

            Console.WriteLine();

            return JavaScriptValue.Invalid;
        }
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:16,代码来源:Program.cs


示例4: DefineHostCallback

        private static void DefineHostCallback(JavaScriptValue globalObject, string callbackName, JavaScriptNativeFunction callback, IntPtr callbackData)
        {
            //
            // Get property ID.
            //

            JavaScriptPropertyId propertyId = JavaScriptPropertyId.FromString(callbackName);

            //
            // Create a function
            //

            JavaScriptValue function = JavaScriptValue.CreateFunction(callback, callbackData);

            //
            // Set the property
            //

            globalObject.SetProperty(propertyId, function, true);
        }
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:20,代码来源:ChakraCoreHost.cs


示例5: JsGetContextOfObject

 internal static extern JavaScriptErrorCode JsGetContextOfObject(JavaScriptValue obj, out JavaScriptContext context);
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:1,代码来源:Native.cs


示例6: JsInstanceOf

 internal static extern JavaScriptErrorCode JsInstanceOf(JavaScriptValue obj, JavaScriptValue constructor, out bool result);
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:1,代码来源:Native.cs


示例7: JsGetIndexedPropertiesExternalData

 internal static extern JavaScriptErrorCode JsGetIndexedPropertiesExternalData(JavaScriptValue obj, IntPtr data, out JavaScriptTypedArrayType arrayType, out uint elementLength);
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:1,代码来源:Native.cs


示例8: JsGetOwnPropertySymbols

 internal static extern JavaScriptErrorCode JsGetOwnPropertySymbols(JavaScriptValue obj, out JavaScriptValue propertySymbols);
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:1,代码来源:Native.cs


示例9: JsGetSymbolFromPropertyId

 internal static extern JavaScriptErrorCode JsGetSymbolFromPropertyId(JavaScriptPropertyId propertyId, out JavaScriptValue symbol);
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:1,代码来源:Native.cs


示例10: JsGetDataViewStorage

 internal static extern JavaScriptErrorCode JsGetDataViewStorage(JavaScriptValue dataView, out byte[] buffer, out uint bufferLength);
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:1,代码来源:Native.cs


示例11: JsGetAndClearException

 internal static extern JavaScriptErrorCode JsGetAndClearException(out JavaScriptValue exception);
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:1,代码来源:Native.cs


示例12: JsCreateURIError

 internal static extern JavaScriptErrorCode JsCreateURIError(JavaScriptValue message, out JavaScriptValue error);
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:1,代码来源:Native.cs


示例13: JsCreateFunction

 internal static extern JavaScriptErrorCode JsCreateFunction(JavaScriptNativeFunction nativeFunction, IntPtr externalData, out JavaScriptValue function);
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:1,代码来源:Native.cs


示例14: JsConstructObject

 internal static extern JavaScriptErrorCode JsConstructObject(JavaScriptValue function, JavaScriptValue[] arguments, ushort argumentCount, out JavaScriptValue result);
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:1,代码来源:Native.cs


示例15: JsCallFunction

 internal static extern JavaScriptErrorCode JsCallFunction(JavaScriptValue function, JavaScriptValue[] arguments, ushort argumentCount, out JavaScriptValue result);
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:1,代码来源:Native.cs


示例16: JsGetArrayBufferStorage

 internal static extern JavaScriptErrorCode JsGetArrayBufferStorage(JavaScriptValue arrayBuffer, out byte[] buffer, out uint bufferLength);
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:1,代码来源:Native.cs


示例17: JsGetTypedArrayStorage

 internal static extern JavaScriptErrorCode JsGetTypedArrayStorage(JavaScriptValue typedArray, out byte[] buffer, out uint bufferLength, out JavaScriptTypedArrayType arrayType, out int elementSize);
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:1,代码来源:Native.cs


示例18: JsSetException

 internal static extern JavaScriptErrorCode JsSetException(JavaScriptValue exception);
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:1,代码来源:Native.cs


示例19: JsCreateSymbol

 internal static extern JavaScriptErrorCode JsCreateSymbol(JavaScriptValue description, out JavaScriptValue symbol);
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:1,代码来源:Native.cs


示例20: JsSetObjectBeforeCollectCallback

 internal static extern JavaScriptErrorCode JsSetObjectBeforeCollectCallback(JavaScriptValue reference, IntPtr callbackState, JavaScriptObjectBeforeCollectCallback beforeCollectCallback);
开发者ID:CedarLogic,项目名称:Chakra-Samples,代码行数:1,代码来源:Native.cs



注:本文中的ChakraHost.Hosting.JavaScriptValue类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ChartboostSDK.CBLocation类代码示例发布时间:2022-05-24
下一篇:
C# Interop.cef_string_t类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap