コード例 #1
0
        /// <summary>
        /// Starts the detail transaction.
        /// </summary>
        /// <param name="fullName">The full name.</param>
        /// <param name="methodName">Name of the method.</param>
        /// <returns>Detail transaction.</returns>
        public TransactionDetail StartDetail(string fullName, string methodName)
        {
            var detail = new TransactionDetail()
            {
                Id         = this.Description.Id,
                FullName   = fullName,
                MethodName = methodName
            };

            this.Description.Descriptions.Add(detail);
            this.BeginDetail?.Invoke(this, detail);
            return(detail);
        }
コード例 #2
0
        /// <summary>
        /// Stops the detail transaction.
        /// </summary>
        /// <param name="detail">The detail started transaction.</param>
        /// <param name="skipTreeTracing">Skip the tree tracing.</param>
        /// <returns>The detail stopped transaction.</returns>
        public TransactionDetail StopDetail(TransactionDetail detail, bool skipTreeTracing = false)
        {
            detail.Stopwatch.Stop();

            if (!skipTreeTracing)
            {
                int count = this.Description.Descriptions.Count - 2;
                if (count >= 0)
                {
                    this.Description.Descriptions.Skip(count).FirstOrDefault()?.Descriptions.Add(detail);
                    this.Description.Descriptions.Remove(detail);
                }
            }

            this.EndDetail?.Invoke(this, detail);
            return(detail);
        }
コード例 #3
0
        /// <inheritdoc/>
        public override IMessage Invoke(IMessage msg)
        {
            if (msg is IMethodCallMessage methodCall)
            {
                if (methodCall.MethodBase is MethodInfo methodInfo)
                {
                    TransactionInstance instance = TransactionInstance.GetInstance(this.httpContext);
                    TransactionDetail   detail   = instance.StartDetail(methodInfo);
                    try
                    {
                        object result = methodInfo.Invoke(this.decorated, methodCall.Args);
                        return(new ReturnMessage(result, methodCall.Args, methodCall.Args.Length, methodCall.LogicalCallContext, methodCall));
                    }
                    finally
                    {
                        instance.StopDetail(detail);
                    }
                }
            }

            return(msg);
        }