/// <summary>
        /// Provides the implementation for operations that invoke an object. Classes derived from the <see cref="T:System.Dynamic.DynamicObject" /> class can override this method to specify dynamic behavior for operations such as invoking an object or a delegate.
        /// </summary>
        /// <param name="binder">Provides information about the invoke operation.</param>
        /// <param name="args">The arguments that are passed to the object during the invoke operation. For example, for the sampleObject(100) operation, where sampleObject is derived from the <see cref="T:System.Dynamic.DynamicObject" /> class, <paramref name="args[0]" /> is equal to 100.</param>
        /// <param name="result">The result of the object invocation.</param>
        /// <returns>
        /// true if the operation is successful; otherwise, false. If this method returns false, the run-time binder of the language determines the behavior. (In most cases, a language-specific run-time exception is thrown.
        /// </returns>
        public override bool TryInvoke(System.Dynamic.InvokeBinder binder, object[] args, out object result)
        {
            //Check if we are toggling the return wrapping mode
            if (args.Length == 1)
            {
                if (args[0] == DynamicReflector.Wrap)
                {
                    if (!typeof(DynamicReflector).IsAssignableFrom(base.Target.GetType()))
                    {
                        base.Target = new DynamicReflector(base.Target);
                    }
                    result = this;
                    return(true);
                }
                else if (args[0] == DynamicReflector.Unwrap)
                {
                    if (typeof(DynamicReflector).IsAssignableFrom(base.Target.GetType()))
                    {
                        base.Target = ((DynamicReflector)base.Target).Target;
                    }
                    result = this;
                    return(true);
                }
            }

            return(base.TryInvoke(binder, args, out result));
        }
Exemple #2
0
 public override bool TryInvoke(System.Dynamic.InvokeBinder binder, object[] args, out object result)
 {
     if (base.TryInvoke(binder, args, out result))
     {
         result = new Win <T>(result);
         return(true);
     }
     return(false);
 }
 public override bool TryInvoke(
     System.Dynamic.InvokeBinder binder, object[] args, out object result)
 {
     result = null;
     if (args.Length == 0)
     {
         TellMyName();
         return(true);
     }
     return(false);
 }
Exemple #4
0
            public override bool TryInvoke(System.Dynamic.InvokeBinder binder, object[] args, out object result)
            {
                result = null;
                if (args.Length != 1 || !(args[0] is int))
                {
                    return(false);
                }

                _handler.Handler((int)args[0]);
                return(true);
            }
 public virtual bool TryInvoke(System.Dynamic.InvokeBinder binder, object[] args, out object result)
 {
     throw null;
 }
 public virtual System.Dynamic.DynamicMetaObject BindInvoke(System.Dynamic.InvokeBinder binder, System.Dynamic.DynamicMetaObject[] args)
 {
     throw null;
 }
 public virtual bool TryInvoke(System.Dynamic.InvokeBinder binder, object[] args, out object result)
 {
     result = default(object); return(default(bool));
 }
 public virtual System.Dynamic.DynamicMetaObject BindInvoke(System.Dynamic.InvokeBinder binder, System.Dynamic.DynamicMetaObject[] args)
 {
     return(default(System.Dynamic.DynamicMetaObject));
 }
        public override bool TryInvoke(System.Dynamic.InvokeBinder binder, Object[] args, out Object result)
        {
            result = default(Object);

            return(default(bool));
        }