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


C# IInvocation.GetConcreteMethod方法代码示例

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


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

示例1: Intercept

        public void Intercept(IInvocation invocation) {
            object instance = ActLikeExtensions.GetInstanceField(invocation.Proxy.GetType(), invocation.Proxy,
                "__target");

            var attr =
                (ActualTypeAttribute[])
                    invocation.GetConcreteMethod().GetCustomAttributes(typeof (ActualTypeAttribute), true);
            var arguments = new List<object>();

            for (int i = 0; i < invocation.Arguments.Length; i++) {
                var type = attr[0].Types[i];
                if (type == null || type == typeof (object))
                    arguments.Add(invocation.Arguments[i]);
                else {
                    var actLike = ActLikeExtensions.ActLike(invocation.Arguments[i], type);
                    arguments.Add(actLike);
                }
            }

            var memebers =
                instance.GetType().GetMethods(BindingFlags.Public | BindingFlags.NonPublic | BindingFlags.Instance);

            var inv = memebers.First(x => x.Name == invocation.GetConcreteMethod().Name);

            invocation.ReturnValue = inv.Invoke(instance, arguments.ToArray());
        }
开发者ID:MaHuJa,项目名称:withSIX.Desktop,代码行数:26,代码来源:Interceptor.cs

示例2: Intercept

        public void Intercept(IInvocation invocation)
        {
            string methodName = invocation.TargetType.FullName + "." + invocation.GetConcreteMethod().Name;

            _logger.Debug( GetDateInLogFormat() + " " + methodName + " Entered");
            invocation.Proceed();
            _logger.Debug( GetDateInLogFormat() + " " + methodName + " Exited");
        }
开发者ID:brucewu16899,项目名称:lacjam,代码行数:8,代码来源:LoggingInterceptor.cs

示例3: Intercept

        public void Intercept(IInvocation invocation)
        {
            // Perform logging here, e.g.:
            var args = string.Join(", ", invocation.Arguments.Select(x => (x ?? string.Empty).ToString()));
            Debug.WriteLine(string.Format("SimpleInjector: {0}({1})", invocation.GetConcreteMethod().Name, args));

            invocation.Proceed();
        }
开发者ID:CodeDux,项目名称:IocPerformance,代码行数:8,代码来源:SimpleInjectorInterceptionLogger.cs

示例4: Intercept

        public void Intercept(IInvocation invocation)
        {
            var attr = invocation.GetConcreteMethod().GetCustomAttributes(typeof(CacheAttribute),false);
            var cacheAttr = attr[0] as CacheAttribute;
            var key = cacheAttr.Key;

            //get data from cache

            invocation.ReturnValue = 10;

            //if not call the invocation.Proceed() the function will not really exec
        }
开发者ID:laball,项目名称:demo,代码行数:12,代码来源:CacheInterceptor.cs

示例5: Intercept

        public void Intercept(IInvocation invocation)
        {
            // Calls the decorated instance.
            invocation.Proceed();


            if (invocation.GetConcreteMethod().Name ==
                NameOfHelper.MethodName<IUrlTrackingService>(x => x.TrackAsync(null)))
            {
                // TrackAsync called
                var trackTask = (Task<UrlTrackingResult>)invocation.ReturnValue;

                // Filtering bots
                if (HttpContext.Current != null)
                {
                    string userAgent = HttpContext.Current.Request.UserAgent;
                    if (!string.IsNullOrEmpty(userAgent))
                    {
                        if (_bots.Any(bot => userAgent.IndexOf(bot, StringComparison.InvariantCultureIgnoreCase) >= 0))
                        {
                            return;
                        }
                    }
                }

                // Checking result
                trackTask.ContinueWith(async t =>
                {
                    UrlTrackingResult trackingResult = t.Result;
                    if (!trackingResult.IsAccountable)
                    {
                        // skip non tariffing redirects
                        return;
                    }

                    try
                    {
                        DomainTrackingStat trackingStat = _mappingEngine.Map<UrlTrackingResult, DomainTrackingStat>(trackingResult);

                        // counting url
                        await _service.CountAsync(trackingStat);
                    }
                    catch (Exception e)
                    {
                        Trace.TraceError(string.Format("Could not count external url '{0}': {1}",
                            trackingResult.Redirect, e));
                    }
                });
            }
        }
开发者ID:GusLab,项目名称:video-portal,代码行数:50,代码来源:UrlTrackingServiceStatInterceptor.cs

示例6: Intercept

        public void Intercept(IInvocation invocation)
        {
            string methodName = invocation.TargetType.FullName + "." + invocation.GetConcreteMethod().Name;

            var arglist = String.Join(", ", invocation.Arguments.Select(arg => arg != null ? arg.ToString() : "<null>"));
            Debug.WriteLine(string.Format("{0}: Entering Campfire API method {1}({2})", Thread.CurrentThread.ManagedThreadId, methodName,
                                          arglist));

            var stopwatch = Stopwatch.StartNew();

            invocation.Proceed();

            Debug.WriteLine("{0}: Leaving Campfire API method {1}({2}). Time taken: {3}",
                            Thread.CurrentThread.ManagedThreadId, methodName, arglist, stopwatch.Elapsed);
        }
开发者ID:Doomblaster,项目名称:MetroFire,代码行数:15,代码来源:CampfireApiLoggingInterceptor.cs

示例7: Intercept

		public void Intercept(IInvocation invocation)
		{
			this.invocation = invocation;
			MethodInfo concreteMethod = invocation.GetConcreteMethod();

			if (invocation.MethodInvocationTarget != null)
			{
				invocation.Proceed();
			}
			else if (concreteMethod.ReturnType.IsValueType && !concreteMethod.ReturnType.Equals(typeof(void)))
			// ensure valid return value
			{
				invocation.ReturnValue = Activator.CreateInstance(concreteMethod.ReturnType);
			}
		}
开发者ID:vbedegi,项目名称:Castle.Core,代码行数:15,代码来源:KeepDataInterceptor.cs

示例8: Intercept

		public void Intercept(IInvocation invocation)
		{
			if (ProfilerInterceptor.ReentrancyCounter > 0)
			{
				CallOriginal(invocation, false);
				return;
			}

			bool callOriginal = false;
			ProfilerInterceptor.GuardInternal(() =>
			{
				var mockInvocation = new Invocation
				{
					Args = invocation.Arguments,
					Method = invocation.GetConcreteMethod(),
					Instance = invocation.Proxy,
				};

				DebugView.TraceEvent(IndentLevel.Dispatch, () => String.Format("Intercepted DP call: {0}", mockInvocation.InputToString()));
				DebugView.PrintStackTrace();

				var mock = MocksRepository.GetMockMixin(invocation.Proxy, invocation.Method.DeclaringType);
				var repo = mock != null ? mock.Repository : this.constructionRepo;

				lock (repo)
				{
					repo.DispatchInvocation(mockInvocation);
				}

				invocation.ReturnValue = mockInvocation.ReturnValue;
				callOriginal = mockInvocation.CallOriginal;

				if (callOriginal)
				{
					DebugView.TraceEvent(IndentLevel.DispatchResult, () => "Calling original implementation");
				}
				else if (mockInvocation.IsReturnValueSet)
				{
					DebugView.TraceEvent(IndentLevel.DispatchResult, () => String.Format("Returning value '{0}'", invocation.ReturnValue));
				}
			});

			if (callOriginal)
				CallOriginal(invocation, true);
		}
开发者ID:BiBongNet,项目名称:JustMockLite,代码行数:45,代码来源:DynamicProxyInterceptor.cs

示例9: Intercept

        public void Intercept(IInvocation invocation)
        {
            var action = invocation.Method.Name;
            var controller = invocation.TargetType.Name.Replace("Controller", "");

            var values = new Dictionary<string, object>();
            var argValues = invocation.Arguments.GetEnumerator();
            foreach (var argument in invocation.GetConcreteMethod().GetParameters())
            {
                argValues.MoveNext();
                if (argValues.Current != null)
                {
                    values.Add(argument.Name, argValues.Current);
                }
            }

            relations.AddToAction(controller, action, values);
        }
开发者ID:AlbertoMonteiro,项目名称:restfulie.net,代码行数:18,代码来源:TransitionInterceptor.cs

示例10: Intercept

        public void Intercept(IInvocation invocation)
        {
            if (instance.ProxyInstance == null)
            {
                invocation.Proceed();
                return;
            }

            var container = instance as IMockExpectationContainer;
            if (container == null)
            {
                invocation.ReturnValue = null;
                return;
            }

            var method = invocation.GetConcreteMethod();
            var arguments = invocation.Arguments;
            var type = method.ReturnType;

            if (container.ExpectationMarked)
            {
                RhinoMocks.Logger.LogExpectation(invocation);

                var expectation = container.GetMarkedExpectation();
                if (expectation.ReturnType.Equals(type))
                {
                    expectation.HandleMethodCall(method, arguments);
                    invocation.ReturnValue = IdentifyDefaultValue(type);
                    return;
                }
                
                var recursive = ParseRecursiveExpectation(container, expectation, type);
                recursive.HandleMethodCall(method, arguments);
                invocation.ReturnValue = recursive.ReturnValue;
                return;
            }

            invocation.ReturnValue = container
                .HandleMethodCall(invocation, method, arguments);
        }
开发者ID:bytedreamer,项目名称:rhino-mocks,代码行数:40,代码来源:ProxyInterceptor.cs

示例11: Intercept

 public void Intercept(IInvocation invocation)
 {
     // Perform logging here, e.g.:
     var args = string.Join(", ", invocation.Arguments.Select(x => x + string.Empty));
     Debug.WriteLine("DryIocInterceptor: {0}({1})", invocation.GetConcreteMethod().Name, args);
     invocation.Proceed();
 }
开发者ID:CodeDux,项目名称:IocPerformance,代码行数:7,代码来源:DryIocAdapter.cs

示例12: PerformAgainst

 ///<summary>
 ///</summary>
 public void PerformAgainst(IInvocation invocation)
 {
     object proxy = mockRepository.GetMockObjectFromInvocationProxy(invocation.Proxy);
     MethodInfo method = invocation.GetConcreteMethod();
     invocation.ReturnValue = mockRepository.MethodCall(invocation, proxy, method, invocation.Arguments);
 }
开发者ID:sneal,项目名称:rhino-mocks,代码行数:8,代码来源:RegularInvocation.cs

示例13: PerformAgainst

 ///<summary>
 ///</summary>
 public void PerformAgainst(IInvocation invocation)
 {
     invocation.ReturnValue = proxyInstance.HandleProperty(invocation.GetConcreteMethod(), invocation.Arguments);
     mockRepository.RegisterPropertyBehaviorOn(proxyInstance);
     return;
 }
开发者ID:sneal,项目名称:rhino-mocks,代码行数:8,代码来源:InvokeProperty.cs

示例14: Intercept

 /// <summary>
 /// Intercepts calls to methods on the class.
 /// </summary>
 /// <param name="invocation">An IInvocation object describing the actual implementation.</param>
 public void Intercept(IInvocation invocation)
 {
     if (invocation.Method.Name == "get_WrappedElement")
     {
         invocation.ReturnValue = this.WrappedElement;
     }
     else
     {
         invocation.ReturnValue = invocation.GetConcreteMethod().Invoke(this.WrappedElement, invocation.Arguments);
     }
 }
开发者ID:v4viveksharma90,项目名称:selenium,代码行数:15,代码来源:PageFactory.cs

示例15: Intercept

 public void Intercept(IInvocation invocation)
 {
     proxyInstance.MockedObjectInstance = invocation.Proxy;
     if (Array.IndexOf(objectMethods, invocation.Method) != -1)
     {
         invocation.Proceed();
         return;
     }
     if (invocation.Method.DeclaringType == typeof (IMockedObject))
     {
         invocation.ReturnValue = invocation.Method.Invoke(proxyInstance, invocation.Arguments);
         return;
     }
     if (proxyInstance.ShouldCallOriginal(invocation.GetConcreteMethod()))
     {
         invocation.Proceed();
         return;
     }
     if (proxyInstance.IsPropertyMethod(invocation.GetConcreteMethod()))
     {
         invocation.ReturnValue = proxyInstance.HandleProperty(invocation.GetConcreteMethod(), invocation.Arguments);
         repository.RegisterPropertyBehaviorOn(proxyInstance);
         return;
     }
     //This call handle the subscribe / remove this method call is for an event,
     //processing then continue normally (so we get an expectation for subscribing / removing from the event
     HandleEvent(invocation, invocation.Arguments);
     object proxy = repository.GetMockObjectFromInvocationProxy(invocation.Proxy);
     MethodInfo method = invocation.GetConcreteMethod();
     invocation.ReturnValue = repository.MethodCall(invocation, proxy, method, invocation.Arguments);
 }
开发者ID:bcraytor,项目名称:rhino-mocks,代码行数:31,代码来源:RhinoInterceptor.cs


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