Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@ -0,0 +1,56 @@
// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using System.Linq;
namespace System.Web.Mvc
{
public class CachedDataAnnotationsMetadataAttributes
{
public CachedDataAnnotationsMetadataAttributes(Attribute[] attributes)
{
DataType = attributes.OfType<DataTypeAttribute>().FirstOrDefault();
Display = attributes.OfType<DisplayAttribute>().FirstOrDefault();
DisplayColumn = attributes.OfType<DisplayColumnAttribute>().FirstOrDefault();
DisplayFormat = attributes.OfType<DisplayFormatAttribute>().FirstOrDefault();
DisplayName = attributes.OfType<DisplayNameAttribute>().FirstOrDefault();
Editable = attributes.OfType<EditableAttribute>().FirstOrDefault();
HiddenInput = attributes.OfType<HiddenInputAttribute>().FirstOrDefault();
ReadOnly = attributes.OfType<ReadOnlyAttribute>().FirstOrDefault();
Required = attributes.OfType<RequiredAttribute>().FirstOrDefault();
ScaffoldColumn = attributes.OfType<ScaffoldColumnAttribute>().FirstOrDefault();
var uiHintAttributes = attributes.OfType<UIHintAttribute>();
UIHint = uiHintAttributes.FirstOrDefault(a => String.Equals(a.PresentationLayer, "MVC", StringComparison.OrdinalIgnoreCase))
?? uiHintAttributes.FirstOrDefault(a => String.IsNullOrEmpty(a.PresentationLayer));
if (DisplayFormat == null && DataType != null)
{
DisplayFormat = DataType.DisplayFormat;
}
}
public DataTypeAttribute DataType { get; protected set; }
public DisplayAttribute Display { get; protected set; }
public DisplayColumnAttribute DisplayColumn { get; protected set; }
public DisplayFormatAttribute DisplayFormat { get; protected set; }
public DisplayNameAttribute DisplayName { get; protected set; }
public EditableAttribute Editable { get; protected set; }
public HiddenInputAttribute HiddenInput { get; protected set; }
public ReadOnlyAttribute ReadOnly { get; protected set; }
public RequiredAttribute Required { get; protected set; }
public ScaffoldColumnAttribute ScaffoldColumn { get; protected set; }
public UIHintAttribute UIHint { get; protected set; }
}
}