public async Task AsynchronousVoidMethod()
        {
            _log.Add(nameof(AsynchronousVoidMethod) + ":Start");
            await Task.Delay(10).ConfigureAwait(false);

            _log.Add(nameof(AsynchronousVoidMethod) + ":End");
        }
        public virtual async Task <Guid> AsynchronousResultMethod()
        {
            _log.Add($"{nameof(AsynchronousResultMethod)}:Start");
            await Task.Delay(10).ConfigureAwait(false);

            _log.Add($"{nameof(AsynchronousResultMethod)}:End");
            return(Guid.NewGuid());
        }
        protected override async Task InterceptAsync(
            IInvocation invocation,
            IInvocationProceedInfo proceedInfo,
            Func <IInvocation, IInvocationProceedInfo, Task> proceed)
        {
            try
            {
                _log.Add($"{invocation.Method.Name}:StartingVoidInvocation");

                if (_asyncB4Proceed)
                {
                    await Task.Yield();
                }

                await proceed(invocation, proceedInfo).ConfigureAwait(false);

                if (_msDelayAfterProceed > 0)
                {
                    await Task.Delay(_msDelayAfterProceed).ConfigureAwait(false);
                }

                _log.Add($"{invocation.Method.Name}:CompletedVoidInvocation");
            }
            catch (Exception e)
            {
                _log.Add($"{invocation.Method.Name}:VoidExceptionThrown:{e.Message}");
                throw;
            }
        }
Ejemplo n.º 4
0
 public Task AsynchronousVoidMethod()
 {
     _log.Add(nameof(AsynchronousVoidMethod) + ":Start");
     _log.Add(nameof(AsynchronousVoidMethod) + ":End");
     return(Task.CompletedTask);
 }
 public void SynchronousVoidMethod()
 {
     _log.Add(nameof(SynchronousVoidMethod) + ":Start");
     Thread.Sleep(10);
     _log.Add(nameof(SynchronousVoidMethod) + ":End");
 }
 protected override void StartingTiming(IInvocation invocation)
 {
     _log.Add($"{invocation.Method.Name}:StartingTiming");
 }
Ejemplo n.º 7
0
 protected override object StartingInvocation(IInvocation invocation)
 {
     _log.Add($"{invocation.Method.Name}:StartingInvocation");
     return(string.Empty);
 }
 protected override string StartingInvocation(IInvocation invocation)
 {
     _log.Add($"{invocation.Method.Name}:StartingInvocation:{RandomValue}");
     return(RandomValue);
 }
 private void LogInterceptStart(IInvocation invocation)
 {
     _log.Add($"{invocation.Method.Name}:InterceptStart");
 }
 protected override object StartingInvocation(IInvocation invocation)
 {
     base.StartingInvocation(invocation);
     _log.Add($"{invocation.Method.Name}:StartingInvocation");
     return(null);
 }