當前位置: 首頁>>代碼示例>>C#>>正文


C# DynamicMetaObject.BindInvoke方法代碼示例

本文整理匯總了C#中System.Dynamic.DynamicMetaObject.BindInvoke方法的典型用法代碼示例。如果您正苦於以下問題:C# DynamicMetaObject.BindInvoke方法的具體用法?C# DynamicMetaObject.BindInvoke怎麽用?C# DynamicMetaObject.BindInvoke使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在System.Dynamic.DynamicMetaObject的用法示例。


在下文中一共展示了DynamicMetaObject.BindInvoke方法的6個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C#代碼示例。

示例1: Bind

        /// <summary>
        /// Performs the binding of the dynamic invoke operation.
        /// </summary>
        /// <param name="target">The target of the dynamic invoke operation.</param>
        /// <param name="args">An array of arguments of the dynamic invoke operation.</param>
        /// <returns>The <see cref="DynamicMetaObject"/> representing the result of the binding.</returns>
        public sealed override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args)
        {
            ContractUtils.RequiresNotNull(target, nameof(target));
            ContractUtils.RequiresNotNullItems(args, nameof(args));

            return target.BindInvoke(this, args);
        }
開發者ID:ChuangYang,項目名稱:corefx,代碼行數:13,代碼來源:InvokeBinder.cs

示例2: TryBindInvoke

 /// <summary>
 /// Tries to perform binding of the dynamic invoke operation.
 /// </summary>    
 /// <param name="binder">An instance of the <see cref="GetMemberBinder"/> that represents the details of the dynamic operation.</param>
 /// <param name="instance">The target of the dynamic operation. </param>
 /// <param name="args">An array of <see cref="DynamicMetaObject"/> instances - arguments to the invoke member operation.</param>
 /// <param name="result">The new <see cref="DynamicMetaObject"/> representing the result of the binding.</param>
 /// <returns>true if operation was bound successfully; otherwise, false.</returns>
 public static bool TryBindInvoke(InvokeBinder binder, DynamicMetaObject instance, DynamicMetaObject[] args, out DynamicMetaObject result) {
     if (TryGetMetaObject(ref instance)) {
         result = instance.BindInvoke(binder, args);
         return true;
     } else {
         result = null;
         return false;
     }
 }
開發者ID:joshholmes,項目名稱:ironruby,代碼行數:17,代碼來源:ComBinder.cs

示例3: TryBindInvoke

        public static bool TryBindInvoke(InvokeBinder binder, DynamicMetaObject instance, DynamicMetaObject[] args, out DynamicMetaObject result) {
            ContractUtils.RequiresNotNull(binder, "binder");
            ContractUtils.RequiresNotNull(instance, "instance");
            ContractUtils.RequiresNotNull(args, "args");
            
            if (TryGetMetaObject(ref instance)) {
                //
                // Demand Full Trust to proceed with the binding.
                //

                new PermissionSet(PermissionState.Unrestricted).Demand();

                result = instance.BindInvoke(binder, args);
                return true;
            } else {
                result = null;
                return false;
            }
        }
開發者ID:jxnmaomao,項目名稱:ironruby,代碼行數:19,代碼來源:ComBinder.cs

示例4: TryBindInvoke

 /// <summary>
 /// Tries to perform binding of the dynamic invoke operation.
 /// </summary>    
 /// <param name="binder">An instance of the <see cref="InvokeBinder"/> that represents the details of the dynamic operation.</param>
 /// <param name="instance">The target of the dynamic operation. </param>
 /// <param name="args">An array of <see cref="DynamicMetaObject"/> instances - arguments to the invoke member operation.</param>
 /// <param name="result">The new <see cref="DynamicMetaObject"/> representing the result of the binding.</param>
 /// <returns>true if operation was bound successfully; otherwise, false.</returns>
 public static bool TryBindInvoke(InvokeBinder binder, DynamicMetaObject instance, DynamicMetaObject[] args, out DynamicMetaObject result) {
     ContractUtils.RequiresNotNull(binder, "binder");
     ContractUtils.RequiresNotNull(instance, "instance");
     ContractUtils.RequiresNotNull(args, "args");
     
     if (TryGetMetaObjectInvoke(ref instance)) {
         result = instance.BindInvoke(binder, args);
         return true;
     } else {
         result = null;
         return false;
     }
 }
開發者ID:TerabyteX,項目名稱:main,代碼行數:21,代碼來源:ComBinder.cs

示例5: Bind

        public sealed override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args) {
            ContractUtils.RequiresNotNull(target, "target");
            ContractUtils.RequiresNotNull(target, "args");

            // there must be only one argument and it is always object[].
            // see SplatCallSite.Invoke
            Debug.Assert(args.Length == 1);
            Debug.Assert(args[0] != null);
            Debug.Assert(args[0].Expression.Type == typeof(object[]));


            // We know it is an array.
            DynamicMetaObject arg = args[0];

            Expression argAsArrayExpr = arg.Expression;

            object[] argValues = (object[])arg.Value;
            int argLen = argValues.Length;

            DynamicMetaObject[] splattedArgs = new DynamicMetaObject[argLen];
            ArgumentInfo[] arginfos = new ArgumentInfo[argLen];

            for (int i = 0; i < argLen; i++) {
                Expression argExpr = Expression.ArrayIndex(
                    argAsArrayExpr,
                    Expression.Constant(i)
                );

                splattedArgs[i] = new DynamicMetaObject(
                    argExpr,
                    BindingRestrictions.Empty,
                    argValues[i]
                );
                arginfos[i] = Expression.ByRefArgument(i);
            }


            BindingRestrictions arrayLenRestriction = BindingRestrictions.GetExpressionRestriction(
                Expression.Equal(
                    Expression.ArrayLength(
                        argAsArrayExpr
                    ),
                    Expression.Constant(argLen)
                )
            );

            ComInvokeAction invokeBinder = new ComInvokeAction(arginfos);
            DynamicMetaObject innerAction = target.BindInvoke(invokeBinder, splattedArgs);

            BindingRestrictions restrictions =
                target.Restrictions.
                Merge(arg.Restrictions).
                Merge(arrayLenRestriction).
                Merge(innerAction.Restrictions);

            return new DynamicMetaObject(
                innerAction.Expression,
                restrictions
            );
        }
開發者ID:joshholmes,項目名稱:ironruby,代碼行數:60,代碼來源:ComInvokeAction.cs

示例6: Bind

 public sealed override DynamicMetaObject Bind(DynamicMetaObject target, DynamicMetaObject[] args)
 {
     ContractUtils.RequiresNotNull(target, "target");
     ContractUtils.RequiresNotNullItems<DynamicMetaObject>(args, "args");
     return target.BindInvoke(this, args);
 }
開發者ID:pritesh-mandowara-sp,項目名稱:DecompliedDotNetLibraries,代碼行數:6,代碼來源:InvokeBinder.cs


注:本文中的System.Dynamic.DynamicMetaObject.BindInvoke方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。