本文整理汇总了C#中IMethodInvocation.Proceed方法的典型用法代码示例。如果您正苦于以下问题:C# IMethodInvocation.Proceed方法的具体用法?C# IMethodInvocation.Proceed怎么用?C# IMethodInvocation.Proceed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类IMethodInvocation
的用法示例。
在下文中一共展示了IMethodInvocation.Proceed方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Invoke
public object Invoke(IMethodInvocation invocation)
{
if (invocation.Method.Name != "GetWebRequest")
return invocation.Proceed();
var request = (WebRequest) invocation.Proceed();
if (request != null)
_modifier.ModifyRequest(request);
return request;
}
示例2: Invoke
public object Invoke(IMethodInvocation invocation)
{
Console.WriteLine("Before: {0}", invocation.Method.Name);
var returnValue = (int)invocation.Proceed() * 2;
Console.WriteLine("After: {0}", invocation.Method.Name);
return returnValue;
}
示例3: Invoke
/// <summary>
/// AOP Alliance invoke call that handles all transaction plumbing.
/// </summary>
/// <param name="invocation">
/// The method that is to execute in the context of a transaction.
/// </param>
/// <returns>The return value from the method invocation.</returns>
public object Invoke(IMethodInvocation invocation)
{
// Work out the target class: may be <code>null</code>.
// The TransactionAttributeSource should be passed the target class
// as well as the method, which may be from an interface.
Type targetType = ( invocation.This != null ) ? invocation.This.GetType() : null;
// If the transaction attribute is null, the method is non-transactional.
TransactionInfo txnInfo = CreateTransactionIfNecessary( invocation.Method, targetType );
object returnValue = null;
try
{
// This is an around advice.
// Invoke the next interceptor in the chain.
// This will normally result in a target object being invoked.
returnValue = invocation.Proceed();
}
catch ( Exception ex )
{
// target invocation exception
CompleteTransactionAfterThrowing( txnInfo, ex );
throw;
}
finally
{
CleanupTransactionInfo( txnInfo );
}
CommitTransactionAfterReturning( txnInfo );
return returnValue;
}
示例4: Invoke
public object Invoke(IMethodInvocation invocation)
{
Console.WriteLine("开始: " + invocation.TargetType.Name + "." + invocation.Method.Name);
object result = invocation.Proceed();
Console.WriteLine("结束: " + invocation.TargetType.Name + "." + invocation.Method.Name);
return result;
}
示例5: Invoke
public object Invoke(IMethodInvocation invocation)
{
ILog log = LogFactory.Create(invocation.TargetType);
object result = invocation.Proceed();
log.Write(invocation.TargetType.Name + "." + invocation.Method.Name, LogLevel.Info);
return result;
}
示例6: Invoke
/// <summary>
/// Handle 'around' advice for services
/// </summary>
public object Invoke(IMethodInvocation invocation)
{
object returnValue = null;
using (Repository repository = new Repository(Repository.SessionFactory))
{
repository.BeginTransaction();
DomainRegistry.Repository = repository;
DomainRegistry.Library = null;
try
{
returnValue = invocation.Proceed();
repository.CommitTransaction();
}
catch (Exception e)
{
returnValue = ServiceResult.Error(invocation.Method.ReturnType, e);
}
}
return returnValue;
}
示例7: Invoke
public object Invoke(IMethodInvocation invocation)
{
var trs = (EventPublishAttribute)invocation.Method.GetCustomAttributes(typeof(EventPublishAttribute), false)[0];
object returnValue = null;
try
{
if (trs.Pointcut == PubulishPointcut.Before || trs.Pointcut == PubulishPointcut.Both)
{
if(_log.IsDebugEnabled)_log.Debug("���ص�һ���¼��������� ǰ��:" + invocation.TargetType.FullName + ", " + invocation.Method.Name);
EventAggregator.Publish(GetEventModel(trs, invocation));
}
returnValue = invocation.Proceed();
if (trs.Pointcut == PubulishPointcut.After || trs.Pointcut == PubulishPointcut.Both)
{
if (_log.IsDebugEnabled) _log.Debug("���ص�һ���¼��������� ����:" + invocation.TargetType.FullName + ", " + invocation.Method.Name);
EventAggregator.Publish(GetEventModel(trs, invocation));
}
}
catch (Exception)
{
throw;
}
return returnValue;
}
示例8: Invoke
public object Invoke(IMethodInvocation invocation)
{
Console.Out.WriteLine("Advice executing; calling the advised method...");
object returnValue = invocation.Proceed();
Console.Out.WriteLine("Advice executed; advised method returned " + returnValue);
return returnValue;
}
示例9: Invoke
public object Invoke(IMethodInvocation invocation)
{
ConsoleLoggingAttribute[] consoleLoggingInfo =
(ConsoleLoggingAttribute[])invocation.Method.GetCustomAttributes(typeof(ConsoleLoggingAttribute), false);
if (consoleLoggingInfo.Length > 0)
{
Color = consoleLoggingInfo[0].Color;
}
ConsoleColor currentColor = Console.ForegroundColor;
Console.ForegroundColor = Color;
Console.Out.WriteLine(String.Format(
"Intercepted call : about to invoke method '{0}'", invocation.Method.Name));
Console.ForegroundColor = currentColor;
object returnValue = invocation.Proceed();
Console.ForegroundColor = Color;
Console.Out.WriteLine(String.Format(
"Intercepted call : returned '{0}'", returnValue));
Console.ForegroundColor = currentColor;
return returnValue;
}
示例10: Invoke
public object Invoke(IMethodInvocation invocation)
{
if (invocation.Method.ReturnType != typeof(string[]))
throw new NotSupportedException(
"StringArrayFilterAdvice must be applied on methods " +
"that return an array of string.");
string[] stringArray = (string[])invocation.Proceed();
if (_pattern.Length > 0)
{
List<string> strings = new List<string>();
foreach (string item in stringArray)
{
if (PatternMatchUtils.SimpleMatch(_pattern, item))
{
strings.Add(item);
}
}
return strings.ToArray();
}
return stringArray;
}
示例11: Invoke
public object Invoke(IMethodInvocation invocation)
{
LOG.Debug("Advice executing; calling the advised method [" + invocation.Method.Name + "]");
object returnValue = invocation.Proceed();
LOG.Debug("Advice executed; advised method [" + invocation.Method.Name + "] returned " + returnValue);
return returnValue;
}
示例12: Invoke
public object Invoke(IMethodInvocation invocation)
{
Console.WriteLine("Before {0} on {1}", invocation.Method.Name, invocation.Method.DeclaringType);
object returnVal = invocation.Proceed();
Console.WriteLine("After {0} on {1}", invocation.Method.Name, invocation.Method.DeclaringType);
return returnVal;
}
示例13: Invoke
public object Invoke(IMethodInvocation invocation)
{
Log("Intercepted call : about to invoke method '{0}'", invocation.Method.Name);
object returnValue = invocation.Proceed();
Log("Intercepted call : returned '{0}'", returnValue);
return returnValue;
}
示例14: Invoke
public object Invoke(IMethodInvocation invocation)
{
String user = HttpContext.Current.User.Identity.Name;
log.Debug(String.Format("{0} - {1} - called by: {2}", invocation.Method.Name, invocation.TargetType.Name,user));
object returnValue = invocation.Proceed();
log.Debug(String.Format("{0} - {1} - finished", invocation.Method.Name, invocation.TargetType.Name));
return returnValue;
}
示例15: Invoke
public object Invoke(IMethodInvocation invocation)
{
Console.WriteLine("Calling {0}({1}) method...",
invocation.Method.Name,
string.Join(", ", invocation.Arguments.Select(a => a.ToString()).ToArray()));
return invocation.Proceed();
}