// 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; using System.Collections.Generic; using System.Linq; using Microsoft.AspNet.Mvc.ApplicationModels; using Microsoft.Framework.Logging; namespace Microsoft.AspNet.Mvc.Logging { /// /// Logging representation of the state of a . Logged during controller discovery. /// public class ControllerModelValues : ReflectionBasedLogValues { public ControllerModelValues(ControllerModel inner) { if (inner != null) { ControllerName = inner.ControllerName; ControllerType = inner.ControllerType.AsType(); ApiExplorer = new ApiExplorerModelValues(inner.ApiExplorer); Actions = inner.Actions.Select(a => new ActionModelValues(a)).ToList(); Attributes = inner.Attributes.Select(a => a.GetType()).ToList(); Filters = inner.Filters.Select(f => new FilterValues(f)).ToList(); ActionConstraints = inner.ActionConstraints?.Select(a => new ActionConstraintValues(a))?.ToList(); RouteConstraints = inner.RouteConstraints.Select( r => new RouteConstraintProviderValues(r)).ToList(); AttributeRoutes = inner.AttributeRoutes.Select( a => new AttributeRouteModelValues(a)).ToList(); Properties = new Dictionary(inner.Properties); } } /// /// The name of the controller. See . /// public string ControllerName { get; } /// /// The of the controller. See . /// public Type ControllerType { get; } /// /// See . /// public ApiExplorerModelValues ApiExplorer { get; } /// /// The actions of the controller as . /// See . /// public IList Actions { get; } /// /// The s of the controller's attributes. /// See . /// public IList Attributes { get; } /// /// The filters on the controller as . /// See . /// public IList Filters { get; } /// /// The action constraints on the controller as . /// See . /// public IList ActionConstraints { get; } /// /// The route constraints on the controller as . /// See . /// public IList RouteConstraints { get; set; } /// /// The attribute routes on the controller as . /// See . /// public IList AttributeRoutes { get; set; } /// /// Gets the set of properties associated with the controller . /// public IDictionary Properties { get; } public override string Format() { return LogFormatter.FormatLogValues(this); } } }