本文整理汇总了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());
}
示例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");
}
示例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();
}
示例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
}
示例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));
}
});
}
}
示例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);
}
示例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);
}
}
示例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);
}
示例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);
}
示例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);
}
示例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();
}
示例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);
}
示例13: PerformAgainst
///<summary>
///</summary>
public void PerformAgainst(IInvocation invocation)
{
invocation.ReturnValue = proxyInstance.HandleProperty(invocation.GetConcreteMethod(), invocation.Arguments);
mockRepository.RegisterPropertyBehaviorOn(proxyInstance);
return;
}
示例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);
}
}
示例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);
}