/// <summary>
        /// Creates a server-side HTTP request activity.
        /// </summary>
        /// <param name="request">A HTTP request.</param>
        /// <param name="relatedActivityId">
        /// A related activity identifier to link activities across component or service
        /// boundaries with a parent activity.
        /// </param>
        /// <returns>A new instance of <see cref="ServerRequestActivity"/>.</returns>
        /// <remarks>
        /// This method is more or less for internal use. Use instead the <c>Thor.AspNetCore</c> package.
        /// </remarks>
        public static ServerRequestActivity Create(
            HttpRequest request,
            Guid?relatedActivityId)
        {
            if (request == null)
            {
                throw new ArgumentNullException(nameof(request));
            }

            ServerRequestActivity context = new ServerRequestActivity();

            if (context._relatedActivityId != Guid.Empty)
            {
                Log.OuterActivityNotAllowed(context.Id);
            }

            if (relatedActivityId != null && relatedActivityId != Guid.Empty)
            {
                Log.BeginTransfer(relatedActivityId.Value);
                Log.Start(context._activityId, request);
                Log.EndTransfer(context._activityId, relatedActivityId.Value);
            }
            else
            {
                Log.Start(context._activityId, request);
            }

            return(context);
        }
        /// <summary>
        /// Creates a server-side HTTP request activity.
        /// </summary>
        /// <param name="method">A HTTP method of a request.</param>
        /// <param name="uri">A HTTP uri of a request.</param>
        /// <param name="relatedActivityId">
        /// A related activity identifier to link activities across component or service
        /// boundaries with a parent activity.
        /// </param>
        /// <returns>A new instance of <see cref="ServerRequestActivity"/>.</returns>
        /// <remarks>
        /// This method is more or less for internal use. Use instead the <c>Thor.AspNetCore</c> package.
        /// </remarks>
        public static ServerRequestActivity Create(string method, Uri uri, Guid?relatedActivityId)
        {
            if (string.IsNullOrWhiteSpace(method))
            {
                throw new ArgumentNullException(nameof(method));
            }
            if (uri == null)
            {
                throw new ArgumentNullException(nameof(uri));
            }

            ServerRequestActivity context = new ServerRequestActivity();

            if (context._relatedActivityId != Guid.Empty)
            {
                Log.OuterActivityNotAllowed(context.Id);
            }

            if (relatedActivityId != null && relatedActivityId != Guid.Empty)
            {
                Log.BeginTransfer(relatedActivityId.Value);
                Log.Start(context._activityId, method, uri.ToString());
                Log.EndTransfer(context._activityId, relatedActivityId.Value);
            }
            else
            {
                Log.Start(context._activityId, method, uri.ToString());
            }

            return(context);
        }