From 43d12539367f5cef0dee86e0ee6db30e5eeddfe0 Mon Sep 17 00:00:00 2001 From: dougbu Date: Fri, 25 Jul 2014 16:51:16 -0700 Subject: [PATCH] Cleanup unused `FormContext` members due to legacy validation removal - provide new property back for customer use - remove unused FieldValidationMetadataClass --- src/Microsoft.AspNet.Mvc.Core/FormContext.cs | 42 ++++++------------- .../Microsoft.AspNet.Mvc.ModelBinding.kproj | 1 - .../Validation/FieldValidationMetadata.cs | 30 ------------- 3 files changed, 12 insertions(+), 61 deletions(-) delete mode 100644 src/Microsoft.AspNet.Mvc.ModelBinding/Validation/FieldValidationMetadata.cs diff --git a/src/Microsoft.AspNet.Mvc.Core/FormContext.cs b/src/Microsoft.AspNet.Mvc.Core/FormContext.cs index e3367dca83..b8e43e7c6c 100644 --- a/src/Microsoft.AspNet.Mvc.Core/FormContext.cs +++ b/src/Microsoft.AspNet.Mvc.Core/FormContext.cs @@ -3,49 +3,31 @@ using System; using System.Collections.Generic; -using Microsoft.AspNet.Mvc.ModelBinding; +using Microsoft.AspNet.Mvc.Rendering; namespace Microsoft.AspNet.Mvc { public class FormContext { - private readonly Dictionary _fieldValidators = - new Dictionary(StringComparer.Ordinal); private readonly Dictionary _renderedFields = new Dictionary(StringComparer.Ordinal); + private Dictionary _formData; - public IDictionary FieldValidators + /// + /// Property bag for any information you wish to associate with a {form/} in an + /// implementation or extension method. + /// + public IDictionary FormData { - get { return _fieldValidators; } - } - - public string FormId { get; set; } - - public bool ReplaceValidationSummary { get; set; } - - public string ValidationSummaryId { get; set; } - - public FieldValidationMetadata GetValidationMetadataForField([NotNull] string fieldName) - { - return GetValidationMetadataForField(fieldName, createIfNotFound: false); - } - - public FieldValidationMetadata GetValidationMetadataForField([NotNull] string fieldName, bool createIfNotFound) - { - FieldValidationMetadata metadata; - if (!FieldValidators.TryGetValue(fieldName, out metadata)) + get { - if (createIfNotFound) + if (_formData == null) { - metadata = new FieldValidationMetadata() - { - FieldName = fieldName - }; - FieldValidators[fieldName] = metadata; + _formData = new Dictionary(StringComparer.Ordinal); } - } - return metadata; + return _formData; + } } public bool RenderedField([NotNull] string fieldName) diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Microsoft.AspNet.Mvc.ModelBinding.kproj b/src/Microsoft.AspNet.Mvc.ModelBinding/Microsoft.AspNet.Mvc.ModelBinding.kproj index 2aecac0d86..c4181d32c6 100644 --- a/src/Microsoft.AspNet.Mvc.ModelBinding/Microsoft.AspNet.Mvc.ModelBinding.kproj +++ b/src/Microsoft.AspNet.Mvc.ModelBinding/Microsoft.AspNet.Mvc.ModelBinding.kproj @@ -84,7 +84,6 @@ - diff --git a/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/FieldValidationMetadata.cs b/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/FieldValidationMetadata.cs deleted file mode 100644 index 4ec711803f..0000000000 --- a/src/Microsoft.AspNet.Mvc.ModelBinding/Validation/FieldValidationMetadata.cs +++ /dev/null @@ -1,30 +0,0 @@ -// 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.Collections.ObjectModel; - -namespace Microsoft.AspNet.Mvc.ModelBinding -{ - public class FieldValidationMetadata - { - private readonly List _validationRules = - new List(); - private string _fieldName = string.Empty; - - public string FieldName - { - get { return _fieldName; } - set { _fieldName = value ?? string.Empty; } - } - - public bool ReplaceValidationMessageContents { get; set; } - - public string ValidationMessageId { get; set; } - - public IList ValidationRules - { - get { return _validationRules; } - } - } -}