97 lines
4.0 KiB
C#
97 lines
4.0 KiB
C#
// 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
|
|
{
|
|
/// <summary>
|
|
/// Logging representation of the state of a <see cref="ControllerModel"/>. Logged during controller discovery.
|
|
/// </summary>
|
|
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<object, object>(inner.Properties);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// The name of the controller. See <see cref="ControllerModel.ControllerName"/>.
|
|
/// </summary>
|
|
public string ControllerName { get; }
|
|
|
|
/// <summary>
|
|
/// The <see cref="Type"/> of the controller. See <see cref="ControllerModel.ControllerType"/>.
|
|
/// </summary>
|
|
public Type ControllerType { get; }
|
|
|
|
/// <summary>
|
|
/// See <see cref="ControllerModel.ApiExplorer"/>.
|
|
/// </summary>
|
|
public ApiExplorerModelValues ApiExplorer { get; }
|
|
|
|
/// <summary>
|
|
/// The actions of the controller as <see cref="ActionModelValues"/>.
|
|
/// See <see cref="ControllerModel.Actions"/>.
|
|
/// </summary>
|
|
public IList<ActionModelValues> Actions { get; }
|
|
|
|
/// <summary>
|
|
/// The <see cref="Type"/>s of the controller's attributes.
|
|
/// See <see cref="ControllerModel.Attributes"/>.
|
|
/// </summary>
|
|
public IList<Type> Attributes { get; }
|
|
|
|
/// <summary>
|
|
/// The filters on the controller as <see cref="FilterValues"/>.
|
|
/// See <see cref="ControllerModel.Filters"/>.
|
|
/// </summary>
|
|
public IList<FilterValues> Filters { get; }
|
|
|
|
/// <summary>
|
|
/// The action constraints on the controller as <see cref="ActionConstraintValues"/>.
|
|
/// See <see cref="ControllerModel.ActionConstraints"/>.
|
|
/// </summary>
|
|
public IList<ActionConstraintValues> ActionConstraints { get; }
|
|
|
|
/// <summary>
|
|
/// The route constraints on the controller as <see cref="RouteConstraintProviderValues"/>.
|
|
/// See <see cref="ControllerModel.RouteConstraints"/>.
|
|
/// </summary>
|
|
public IList<RouteConstraintProviderValues> RouteConstraints { get; set; }
|
|
|
|
/// <summary>
|
|
/// The attribute routes on the controller as <see cref="AttributeRouteModelValues"/>.
|
|
/// See <see cref="ControllerModel.AttributeRoutes"/>.
|
|
/// </summary>
|
|
public IList<AttributeRouteModelValues> AttributeRoutes { get; set; }
|
|
|
|
/// <summary>
|
|
/// Gets the set of properties associated with the controller <see cref="ControllerModel.Properties"/>.
|
|
/// </summary>
|
|
public IDictionary<object, object> Properties { get; }
|
|
|
|
public override string Format()
|
|
{
|
|
return LogFormatter.FormatLogValues(this);
|
|
}
|
|
}
|
|
} |