/// <summary>
            /// 执行
            /// </summary>
            /// <param name="paramValues"></param>
            /// <returns></returns>
            public object Invoke(object[] paramValues)
            {
                var instance = Activator.CreateInstance(InstanceType);
                //找到正确的参数对应顺序
                var parameterlist = InvokeMethod.GetParameters().Select(p => p.Name.ToLower()).ToList();
                var matchs        = _reg_brace_p_.Matches(Route);
                var l             = new List <string>();

                foreach (Match m in matchs)
                {
                    var key = m.Value.ToLower().Replace("{", "").Replace("}", "");
                    l.Add(key);
                }
                var newp = new List <object>();

                foreach (var item in parameterlist)
                {
                    if (l.Contains(item))
                    {
                        newp.Add(paramValues[l.IndexOf(item)]);
                    }
                }
                if (HasParentParameter)
                {
                    newp.Add(paramValues.Last());
                }

                return(InvokeMethod.Invoke(instance, newp.ToArray()));
            }
        public static LambdaParameterWrapper InvokeIndexer(object obj, object[] args)
        {
            if (obj == null)
            {
                throw new NullReferenceException(String.Format("Indexer target is null"));
            }
            if (obj is LambdaParameterWrapper)
            {
                obj = ((LambdaParameterWrapper)obj).Value;
            }

            var argsResolved = new object[args.Length];

            for (int i = 0; i < args.Length; i++)
            {
                argsResolved[i] = args[i] is LambdaParameterWrapper ? ((LambdaParameterWrapper)args[i]).Value : args[i];
            }

            if (obj is Array)
            {
                var objArr = (Array)obj;
                if (objArr.Rank != args.Length)
                {
                    throw new RankException(String.Format("Array rank ({0}) doesn't match number of indicies ({1})",
                                                          objArr.Rank, args.Length));
                }
                var indicies = new long[argsResolved.Length];
                for (int i = 0; i < argsResolved.Length; i++)
                {
                    indicies[i] = ConvertManager.ChangeType <long>(argsResolved[i]);
                }

                var res = objArr.GetValue(indicies);
                return(new LambdaParameterWrapper(res));
            }
            else
            {
                // indexer method
                var invoke = new InvokeMethod(obj, "get_Item");
                var res    = invoke.Invoke(argsResolved);
                return(new LambdaParameterWrapper(res));
            }
        }
        public static LambdaParameterWrapper InvokeMethod(object obj, string methodName, object[] args)
        {
            if (obj is LambdaParameterWrapper)
            {
                obj = ((LambdaParameterWrapper)obj).Value;
            }

            if (obj == null)
            {
                throw new NullReferenceException(String.Format("Method {0} target is null", methodName));
            }

            var argsResolved = new object[args.Length];

            for (int i = 0; i < args.Length; i++)
            {
                argsResolved[i] = args[i] is LambdaParameterWrapper ? ((LambdaParameterWrapper)args[i]).Value : args[i];
            }

            var invoke = new InvokeMethod(obj, methodName);
            var res    = invoke.Invoke(argsResolved);

            return(new LambdaParameterWrapper(res));
        }
		public static LambdaParameterWrapper InvokeMethod(object obj, string methodName, object[] args) {
			if (obj is LambdaParameterWrapper)
				obj = ((LambdaParameterWrapper)obj).Value;

			if (obj == null)
				throw new NullReferenceException(String.Format("Method {0} target is null", methodName));

			var argsResolved = new object[args.Length];
			for (int i = 0; i < args.Length; i++)
				argsResolved[i] = args[i] is LambdaParameterWrapper ? ((LambdaParameterWrapper)args[i]).Value : args[i];

			var invoke = new InvokeMethod(obj, methodName);
			var res = invoke.Invoke(argsResolved);
			return new LambdaParameterWrapper(res);
		}
		public static LambdaParameterWrapper InvokeIndexer(object obj, object[] args) {
			if (obj == null)
				throw new NullReferenceException(String.Format("Indexer target is null"));
			if (obj is LambdaParameterWrapper)
				obj = ((LambdaParameterWrapper)obj).Value;

			var argsResolved = new object[args.Length];
			for (int i = 0; i < args.Length; i++)
				argsResolved[i] = args[i] is LambdaParameterWrapper ? ((LambdaParameterWrapper)args[i]).Value : args[i];

			if (obj is Array) {
				var objArr = (Array)obj;
				if (objArr.Rank != args.Length) {
					throw new RankException(String.Format("Array rank ({0}) doesn't match number of indicies ({1})",
						objArr.Rank, args.Length));
				}
				var indicies = new int[argsResolved.Length];
				for (int i = 0; i < argsResolved.Length; i++)
					indicies[i] = Convert.ToInt32(argsResolved[i]);

				var res = objArr.GetValue(indicies);
				return new LambdaParameterWrapper(res);
			} else {
				// indexer method
				var invoke = new InvokeMethod(obj, "get_Item");
				var res = invoke.Invoke(argsResolved);
				return new LambdaParameterWrapper(res);
			}
		}
 /// <summary>
 /// Invoke the callback function. Throws if the callback has no function pointer assigned.
 /// </summary>
 /// <param name="args">Arguments to the callback function.</param>
 public void Invoke(params object[] args)
 {
     PrepareInvoke();
     InvokeMethod.Invoke(Delegate, args);
 }