コード例 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="AuditInfo{T}"/> class.
        /// </summary>
        /// <param name="requestContext"> The request context to extract user and action information. </param>
        public AuditInfo(RequestContext requestContext)
        {
            requestContext
            .ArgumentMustNotBeNull("requestContext")
            .ArgumentPropertyMustNotBeNull("requestContext", "RouteData", x => x.RouteData)
            .ArgumentPropertyMustNotBeNull("requestContext", "RouteData.Values", x => x.RouteData.Values)
            .ArgumentPropertyMustNotBeNull("requestContext", "HttpContext", x => x.HttpContext)
            .ArgumentPropertyMustNotBeNull("requestContext", "HttpContext.User", x => x.HttpContext.User);

            this.Action = requestContext.RouteData.Values.Aggregate(string.Empty, (c, x) => c + "=>" + x.Value);
            this.User   = requestContext.HttpContext.User.Identity.Name;
        }