当前位置: 首页>>代码示例>>C#>>正文


C# PValue.DynamicCall方法代码示例

本文整理汇总了C#中PValue.DynamicCall方法的典型用法代码示例。如果您正苦于以下问题:C# PValue.DynamicCall方法的具体用法?C# PValue.DynamicCall怎么用?C# PValue.DynamicCall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在PValue的用法示例。


在下文中一共展示了PValue.DynamicCall方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Test1

        /* function foo(a) [share c]
         * {
         *    var b;
         *    var d;
         *    return ->d;
         * }
        */

        public static void Test1(StackContext sctx, PValue[] args, PVariable[] sharedVariables,
            out PValue result)
        {
            var a = args[0];
            var b = PType.Null.CreatePValue();
            var c = sharedVariables[0];
            var d = new PVariable();
            d.Value = PType.Null;

            var argv = new[] {a, b};

            a = new PValue(true, PType.Bool);
            b = sctx.CreateNativePValue(sctx.ParentApplication.Functions["funcid"]);

            a.DynamicCall(sctx, null, PCall.Get, "memid");

            result = sctx.CreateNativePValue(d);
        }
开发者ID:SealedSun,项目名称:prx,代码行数:26,代码来源:CilTestCommand.cs

示例2: _wrapDynamicIEnumerable

 private static IEnumerable<PValue> _wrapDynamicIEnumerable(StackContext sctx, PValue psource)
 {
     var pvEnumerator =
         psource.DynamicCall(sctx, Runtime.EmptyPValueArray, PCall.Get, "GetEnumerator").
             ConvertTo(sctx, typeof (IEnumerator));
     var enumerator = (IEnumerator) pvEnumerator.Value;
     PValueEnumerator pvEnum;
     try
     {
         if ((pvEnum = enumerator as PValueEnumerator) != null)
         {
             while (pvEnum.MoveNext())
                 yield return pvEnum.Current;
         }
         else
         {
             while (enumerator.MoveNext())
                 yield return sctx.CreateNativePValue(enumerator.Current);
         }
     }
     finally
     {
         var disposable = enumerator as IDisposable;
         if (disposable != null)
             disposable.Dispose();
     }
 }
开发者ID:SealedSun,项目名称:prx,代码行数:27,代码来源:Map.cs

示例3: Run

        /// <summary>
        ///     Implementation of (obj, id, arg1, arg2, arg3, ..., argn) => obj.id(arg1, arg2, arg3, ..., argn);
        /// </summary>
        /// <param name = "sctx">The stack context in which to call the member of <paramref name = "obj" />.</param>
        /// <param name = "obj">The obj to call.</param>
        /// <param name = "isSet">Indicates whether to perform a Set-call.</param>
        /// <param name = "id">The id of the member to call.</param>
        /// <param name = "args">The array of arguments to pass to the member call.<br />
        ///     Lists and coroutines are expanded.</param>
        /// <returns>The result returned by the member call.</returns>
        /// <exception cref = "ArgumentNullException"><paramref name = "sctx" /> is null.</exception>
        public PValue Run(StackContext sctx, PValue obj, bool isSet, string id, params PValue[] args)
        {
            if (obj == null)
                return PType.Null.CreatePValue();
            if (sctx == null)
                throw new ArgumentNullException("sctx");
            if (args == null)
                args = new PValue[] {};

            var iargs = new List<PValue>();
            for (var i = 0; i < args.Length; i++)
            {
                var arg = args[i];
                var folded = Map._ToEnumerable(sctx, arg);
                if (folded == null)
                    iargs.Add(arg);
                else
                    iargs.AddRange(folded);
            }

            return obj.DynamicCall(sctx, iargs.ToArray(), isSet ? PCall.Set : PCall.Get, id);
        }
开发者ID:SealedSun,项目名称:prx,代码行数:33,代码来源:Call_Member.cs


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