// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. // Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. using System.Collections.Generic; using System.Linq; using System.Reflection; using Microsoft.AspNet.Mvc.ApplicationModels; using Microsoft.Framework.Logging; namespace Microsoft.AspNet.Mvc.Logging { /// /// Represents the state of an . /// Logged as a substructure of /// public class ActionModelValues : LoggerStructureBase { // note: omit the controller as this structure is nested inside the ControllerModelValues it belongs to public ActionModelValues(ActionModel inner) { if (inner != null) { ActionName = inner.ActionName; ActionMethod = inner.ActionMethod; ApiExplorer = new ApiExplorerModelValues(inner.ApiExplorer); Parameters = inner.Parameters.Select(p => new ParameterModelValues(p)).ToList(); RouteConstraints = inner.RouteConstraints.Select( r => new RouteConstraintProviderValues(r)).ToList(); Filters = inner.Filters.Select(f => new FilterValues(f)).ToList(); if (inner.AttributeRouteModel != null) { AttributeRouteModel = new AttributeRouteModelValues(inner.AttributeRouteModel); } HttpMethods = inner.HttpMethods; ActionConstraints = inner.ActionConstraints?.Select(a => new ActionConstraintValues(a))?.ToList(); Properties = new Dictionary(inner.Properties); } } /// /// The name of the action. See . /// public string ActionName { get; } /// /// The method info of the action. See . /// public MethodInfo ActionMethod { get; } /// /// See . /// public ApiExplorerModelValues ApiExplorer { get; } /// /// The parameters of the action as . /// See . /// public IList Parameters { get; } /// /// The filters of the action as . /// See . /// public IList Filters { get; } /// /// The route constraints on the controller as . /// See . /// public IList RouteConstraints { get; set; } /// /// The attribute route model of the action as . /// See . /// public AttributeRouteModelValues AttributeRouteModel { get; } /// /// The http methods this action supports. See . /// public IList HttpMethods { get; } /// /// The action constraints of the action as . /// See . /// public IList ActionConstraints { get; } /// /// Gets the set of properties associated with the action . /// public IDictionary Properties { get; } public override string Format() { return LogFormatter.FormatStructure(this); } } }