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


C# Dynamic.InvokeBinder类代码示例

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


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

示例1: TryInvoke

        public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
        {
            if (binder == null) throw new ArgumentNullException("binder");

            if (Resource(args, out result))
                return true;

            if (Query(args, out result))
                return true;

            if (Extensions.IsHttpVerb(GetLastCall()))
            {
                result = HttpVerb(args);
                return true;
            }

            var builder = new StringBuilder(_callLog);
            foreach (var t in args)
            {
                builder.Append("/");
                var s = t as string;
                if (s != null)
                    builder.Append("@\"").Append(s.Replace("\"", "\"\"")).Append("\"");
                else
                    builder.Append(t);
            }

            result = new MemberAccessWrapper(_httpClientWrapper, _baseUri, builder.ToString());

            return true;
        }
开发者ID:tsteele,项目名称:DalSoft.RestClient,代码行数:31,代码来源:MemberAccessWrapper.cs

示例2: BindInvoke

 public override Meta BindInvoke(InvokeBinder binder, Meta[] args)
 {
     return new Meta(
         Et.Call(
             EtUtils.Cast<IFunction>(
                 this.Expression
             ),
             IFunctionMethods.MiCall,
             EtUtils.Cast<IObj>(
                 args[0].Expression
             ),
             AstUtils.NewArrayHelper(
                 typeof(object),
                 DynamicUtils.GetExpressions(
                     ArrayUtils.RemoveFirst(args)
                 )
             )
         ),
         RestrictUtils.BuildCallRestrictions(
             this,
             args,
             RestrictFlag.Type
         )
     );
 }
开发者ID:dtdimi,项目名称:IronJS,代码行数:25,代码来源:IFunctionMeta.cs

示例3: DelegateInfo

        internal DelegateInfo(LanguageContext context, Type returnType, ParameterInfo[] parameters) {
            Assert.NotNull(returnType);
            Assert.NotNullItems(parameters);

            _returnType = returnType;
            _parameters = parameters;

            PerfTrack.NoteEvent(PerfTrack.Categories.DelegateCreate, ToString());

            if (_returnType != typeof(void)) {
                _convertBinder = context.CreateConvertBinder(_returnType, true);
            }

            _invokeBinder = context.CreateInvokeBinder(new CallInfo(_parameters.Length));

            Type[] delegateParams = new Type[_parameters.Length];
            for (int i = 0; i < _parameters.Length; i++) {
                delegateParams[i] = _parameters[i].ParameterType;
            }

            // Create the method with a special name so the langauge compiler knows that method's stack frame is not visible
            DynamicILGen cg = Snippets.Shared.CreateDynamicMethod("_Scripting_", _returnType, ArrayUtils.Insert(typeof(object[]), delegateParams), false);

            // Emit the stub
            _constants = EmitClrCallStub(cg);
            _method = cg.Finish();
        }
开发者ID:BenHall,项目名称:ironruby,代码行数:27,代码来源:DelegateInfo.cs

示例4: TryInvoke

 public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
 {
     output.Write(string.Format("Try invoke with {0} arguments {1} and return type is {2}",
         binder.CallInfo.ArgumentCount, string.Join(", ", binder.CallInfo.ArgumentNames), binder.ReturnType.FullName));
     var res = baseElement.TryInvoke(binder, args, out result);
     return true;
 }
开发者ID:baks,项目名称:Simple.Xml,代码行数:7,代码来源:VerboseElement.cs

示例5: TryInvoke

        public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
        {
			var innerResult = _inner.TryInvoke(binder, args, out result);
			//special case, we need to check if the result is of a non-legacy dynamic type because if it is, we need 
			//to return the legacy type
			result = LegacyConverter.ConvertToLegacy(result);
			return innerResult;
        }
开发者ID:elrute,项目名称:Triphulcas,代码行数:8,代码来源:DynamicNull.cs

示例6: TryInvoke

        public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
        {
            Console.WriteLine("TryInvoke is called");
            bool tryResult = base.TryInvoke(binder, args, out result);

            return true;

        }
开发者ID:HK-Zhang,项目名称:Grains,代码行数:8,代码来源:DynamicProduct.cs

示例7: ParseArgs

 public static ImmutableDictionary<string, object> ParseArgs(object[] args, InvokeBinder binder)
 {
     if (binder.CallInfo.ArgumentCount == 0) return Empty;
     if (binder.CallInfo.ArgumentCount == 1 && (binder.CallInfo.ArgumentNames.Count == 0 || string.IsNullOrWhiteSpace(binder.CallInfo.ArgumentNames[0])))
     {
         return ObjectToDictionary(args[0]);
     }
     return ArgsToDictionary(args, binder);
 }
开发者ID:RendleLabs,项目名称:Simple.Data.Core,代码行数:9,代码来源:ReadBinder.cs

示例8: BindInvoke

 public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args)
 {
     return new DynamicMetaObject(
         Expression.Call(
             Expression.Constant(Function),
             typeof(BonsaiFunction).GetMethod("Call"),
             Expression.NewArrayInit(typeof(object), args.Select(a => Expression.Convert(a.Expression, typeof(object))))),
         BindingRestrictions.GetInstanceRestriction(this.Expression, Function));
 }
开发者ID:eugen,项目名称:Bonsai,代码行数:9,代码来源:BonsaiFunction.cs

示例9: 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

示例10: TryInvoke

 /// <summary>
 /// Tries the invoke.
 /// </summary>
 /// <param name="binder">The binder.</param>
 /// <param name="args">The args.</param>
 /// <param name="result">The result.</param>
 /// <returns></returns>
 public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
 {
     result = null;
     if (args.Length == 1 && args.First() is String)
     {
         result = _lookup(args[0] as String);
         return true;
     }
     return false;
 }
开发者ID:ekonbenefits,项目名称:dynamitey,代码行数:17,代码来源:FluentStringLookup.cs

示例11: TryInvoke

 public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
 {
     IodineObject[] arguments = new IodineObject[args.Length];
     for (int i = 0; i < args.Length; i++) {
         arguments [i] = typeRegistry.ConvertToIodineObject (args [i]);
     }
     IodineObject returnVal = internalObject.Invoke (internalVm, arguments);
     result = typeRegistry.ConvertToNativeObject (returnVal);
     return true;
 }
开发者ID:splitandthechro,项目名称:nginz,代码行数:10,代码来源:IodineDynamicObject.cs

示例12: TryInvoke

 /// <summary>
 /// Evaluates JavaScript directly within the context of the target object.
 /// Particularly useful for expressing lambdas, but can be used to execute any JavaScript that cannot be expressed in C#.
 /// </summary>
 /// <example>
 /// var visibleText = elements("filter(e => e.visible).map(e => e.textContent)");
 /// </example>
 public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
 {
     try
     {
         var script = "this." + args.Single().ToString();
         result = target.eval(script).Result;
         if (result is ExpandoObject) result = new Bridge(result);
         return true;
     }
     catch (AggregateException e) { throw e.InnerException; }
 }
开发者ID:ColinOrr,项目名称:zombie.net,代码行数:18,代码来源:Bridge.cs

示例13: TryInvoke

        public override bool TryInvoke(InvokeBinder binder, object[] args, out object result)
        {
            if (!commands.Any())
            {
                result = null;
                return true;
            }

            var runOptions = new RunOptions(this);
            result = Runner.Run(runOptions);
            return true;
        }
开发者ID:rlaneve,项目名称:cmd,代码行数:12,代码来源:Cmd.cs

示例14: BindInvoke

        public override DynamicMetaObject BindInvoke(InvokeBinder binder, DynamicMetaObject[] args) {
            ContractUtils.RequiresNotNull(binder, "binder");

            ComMethodDesc method;
            if (_self.TryGetGetItem(out method)) {

                bool[] isByRef = ComBinderHelpers.ProcessArgumentsForCom(ref args);
                return BindComInvoke(args, method, binder.CallInfo, isByRef);
            }

            return base.BindInvoke(binder, args);
        }
开发者ID:jcteague,项目名称:ironruby,代码行数:12,代码来源:IDispatchMetaObject.cs

示例15: Bind

            public static DynamicMetaObject/*!*/ Bind(RubyContext/*!*/ context, InvokeBinder/*!*/ binder,
                RubyMetaObject/*!*/ target, DynamicMetaObject/*!*/[]/*!*/ args, Action<MetaObjectBuilder, CallArguments>/*!*/ buildInvoke) {

                RubyCallSignature callSignature;
                if (RubyCallSignature.TryCreate(binder.CallInfo, out callSignature)) {
                    return binder.FallbackInvoke(target, args);
                }

                var metaBuilder = new MetaObjectBuilder();
                buildInvoke(metaBuilder, new CallArguments(target.CreateMetaContext(), target, args, callSignature));
                return metaBuilder.CreateMetaObject(binder);
            }
开发者ID:tnachen,项目名称:ironruby,代码行数:12,代码来源:InteropBinder.cs


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