本文整理汇总了C#中IInvocation.GetConcreteMethodInvocationTarget方法的典型用法代码示例。如果您正苦于以下问题:C# IInvocation.GetConcreteMethodInvocationTarget方法的具体用法?C# IInvocation.GetConcreteMethodInvocationTarget怎么用?C# IInvocation.GetConcreteMethodInvocationTarget使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IInvocation
的用法示例。
在下文中一共展示了IInvocation.GetConcreteMethodInvocationTarget方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: InvokeOnCurrentInstance
static object InvokeOnCurrentInstance(IInvocation invocation)
{
Type pluginType = invocation.TargetType;
EventDetails eventDetails = EnsureInitializedAndEnabled(pluginType);
MethodInfo method = invocation.GetConcreteMethodInvocationTarget();
return method.Invoke(eventDetails.Event, invocation.Arguments);
}
示例2: MakeInterception
protected override void MakeInterception(IInvocation invocation)
{
var parameters = invocation.GetConcreteMethodInvocationTarget().GetParameters().Select(a => a.Name);
Logger.DebugFormat("{0} - TargetType: {1}", InterceptorName, invocation.TargetType);
Logger.DebugFormat("{0} - Method.Name: {1}", InterceptorName, invocation.Method.Name);
Logger.DebugFormat("{0} - Parameters: {1}", InterceptorName, string.Join(", ", parameters));
invocation.Proceed();
}
示例3: Intercept
public void Intercept(IInvocation invocation)
{
var joinPoint = new JoinPoint
{
Arguments = invocation.Arguments,
MethodInfo = invocation.GetConcreteMethodInvocationTarget(),
ReturnValue = invocation.ReturnValue,
TargetObject = invocation.InvocationTarget,
TargetType = invocation.TargetType,
ExecuteMethodFromProxy = (() =>
{
invocation.Proceed();
return invocation.ReturnValue;
}),
SetReturnValueToProxy = ((o) => invocation.ReturnValue = o)
};
var typesToApply = _types.Where(x => _pointCut.CanApply(joinPoint, x)).ToArray();
if (typesToApply.Length > 0)
{
var aspectsToApply = typesToApply.Select(x => _container.Resolve(x) as IAspect).ToArray();
aspectsToApply = aspectsToApply.OrderBy(x => x.GetOrder(joinPoint)).ToArray();
var root = aspectsToApply[0];
var aspect = root;
for (var i = 1; i < aspectsToApply.Length; i++)
{
aspect.NextAspect = aspectsToApply[i];
aspect = aspect.NextAspect;
}
root.Apply(joinPoint);
}
else
{
invocation.Proceed();
}
}
示例4: GetCacheKey
private static string GetCacheKey(IInvocation invocation)
{
var fullName = invocation.TargetType.FullName;
var method = invocation.Method.Name;
var argumentNames = invocation.GetConcreteMethodInvocationTarget().GetParameters().Select(a => a.Name);
var argumentValues = string.Join("_", invocation.Arguments);
return string.Format(
"{0}_{1}_{2}_{3}",
fullName,
method,
string.Join("_", argumentNames),
argumentValues);
}
示例5: Intercept
/// <summary>
/// Intercepts the specified invocation.
/// </summary>
/// <param name="invocation">The invocation.</param>
public void Intercept(IInvocation invocation)
{
MethodInfo method = invocation.GetConcreteMethodInvocationTarget();
RemoteMethodInfo remoteMethod = null;
if (method.DeclaringType == typeof(IRemoteCaller)) {
invocation.ReturnValue = method.Invoke(invocation.InvocationTarget, invocation.Arguments);
return;
}
remoteMethod = InterfaceConfigLoader.GetServiceInfo(method);
if (!remoteMethod.Offline)
{
if (invocation.Method.IsDefined(typeof(ClientCacheAttribute), true))
{
// 获取缓存结果
if (ClientCacheManager.HasCache(method, invocation.Arguments))
invocation.ReturnValue = ClientCacheManager.GetCachedData(method, invocation.Arguments);
else
{
// 第一次调用
object result = InvokeCommand(method, invocation.Arguments);
ClientCacheManager.RegisterCache(method, result, remoteMethod.DataUpdateEvent, invocation.Arguments);
invocation.ReturnValue = result;
}
}
else
invocation.ReturnValue = InvokeCommand(method, invocation.Arguments);
}
else
{
if (invocation.Method.IsDefined(typeof(ClientCacheAttribute), true))
{
if (ClientCacheManager.HasCache(method, invocation.Arguments))
invocation.ReturnValue = ClientCacheManager.GetCachedData(method, invocation.Arguments);
else
{
object result = InvokeCommand(method, invocation.Arguments);
ClientCacheManager.RegisterCache(method, result, remoteMethod.DataUpdateEvent, invocation.Arguments);
invocation.ReturnValue = result;
}
}
else
OfflineProcess(invocation.Method, invocation.Arguments); // 调用离线处理方法
}
}
示例6: MakeInterception
protected override void MakeInterception(IInvocation invocation)
{
var args = invocation.GetConcreteMethodInvocationTarget().GetParameters();
var failedArgs = args
.Where(a =>
a.IsDefined(typeof (NotNullAttribute), true) &&
(invocation.Arguments[a.Position] == null));
if (failedArgs.Any())
{
Logger.DebugFormat(
"{0} - Argument(s) that failed NotNull-inspection: {1}",
InterceptorName,
string.Join(", ", failedArgs.Select(a => a.Name)));
throw new ArgumentNullException(failedArgs.First().Name);
}
Logger.DebugFormat("{0} - Arguments passed NotNull-inspection.", InterceptorName);
invocation.Proceed();
}
示例7: Handle
public bool Handle(IInvocation invocation)
{
return VerifyReturnTypeIsServiceReply(invocation.GetConcreteMethodInvocationTarget().ReturnType);
}
示例8: CreateErrorResponse
public object CreateErrorResponse(IInvocation invocation, BusinessException exception)
{
return CreateFailedServiceReply(invocation.GetConcreteMethodInvocationTarget().ReturnType,
new ServiceFault(exception));
}