Cleanup unused `FormContext` members due to legacy validation removal
- provide new property back for customer use - remove unused FieldValidationMetadataClass
This commit is contained in:
parent
b5dcc9895d
commit
43d1253936
|
|
@ -3,49 +3,31 @@
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using Microsoft.AspNet.Mvc.ModelBinding;
|
using Microsoft.AspNet.Mvc.Rendering;
|
||||||
|
|
||||||
namespace Microsoft.AspNet.Mvc
|
namespace Microsoft.AspNet.Mvc
|
||||||
{
|
{
|
||||||
public class FormContext
|
public class FormContext
|
||||||
{
|
{
|
||||||
private readonly Dictionary<string, FieldValidationMetadata> _fieldValidators =
|
|
||||||
new Dictionary<string, FieldValidationMetadata>(StringComparer.Ordinal);
|
|
||||||
private readonly Dictionary<string, bool> _renderedFields =
|
private readonly Dictionary<string, bool> _renderedFields =
|
||||||
new Dictionary<string, bool>(StringComparer.Ordinal);
|
new Dictionary<string, bool>(StringComparer.Ordinal);
|
||||||
|
private Dictionary<string, object> _formData;
|
||||||
|
|
||||||
public IDictionary<string, FieldValidationMetadata> FieldValidators
|
/// <summary>
|
||||||
|
/// Property bag for any information you wish to associate with a {form/} in an <see cref="IHtmlHelper"/>
|
||||||
|
/// implementation or extension method.
|
||||||
|
/// </summary>
|
||||||
|
public IDictionary<string, object> FormData
|
||||||
{
|
{
|
||||||
get { return _fieldValidators; }
|
get
|
||||||
}
|
|
||||||
|
|
||||||
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))
|
|
||||||
{
|
{
|
||||||
if (createIfNotFound)
|
if (_formData == null)
|
||||||
{
|
{
|
||||||
metadata = new FieldValidationMetadata()
|
_formData = new Dictionary<string, object>(StringComparer.Ordinal);
|
||||||
{
|
|
||||||
FieldName = fieldName
|
|
||||||
};
|
|
||||||
FieldValidators[fieldName] = metadata;
|
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return metadata;
|
return _formData;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public bool RenderedField([NotNull] string fieldName)
|
public bool RenderedField([NotNull] string fieldName)
|
||||||
|
|
|
||||||
|
|
@ -84,7 +84,6 @@
|
||||||
<Compile Include="Validation\DataMemberModelValidatorProvider.cs" />
|
<Compile Include="Validation\DataMemberModelValidatorProvider.cs" />
|
||||||
<Compile Include="Validation\DataTypeAttributeAdapter.cs" />
|
<Compile Include="Validation\DataTypeAttributeAdapter.cs" />
|
||||||
<Compile Include="Validation\ErrorModelValidator.cs" />
|
<Compile Include="Validation\ErrorModelValidator.cs" />
|
||||||
<Compile Include="Validation\FieldValidationMetadata.cs" />
|
|
||||||
<Compile Include="Validation\IClientModelValidator.cs" />
|
<Compile Include="Validation\IClientModelValidator.cs" />
|
||||||
<Compile Include="Validation\IModelValidator.cs" />
|
<Compile Include="Validation\IModelValidator.cs" />
|
||||||
<Compile Include="Validation\IModelValidatorProvider.cs" />
|
<Compile Include="Validation\IModelValidatorProvider.cs" />
|
||||||
|
|
|
||||||
|
|
@ -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<ModelClientValidationRule> _validationRules =
|
|
||||||
new List<ModelClientValidationRule>();
|
|
||||||
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<ModelClientValidationRule> ValidationRules
|
|
||||||
{
|
|
||||||
get { return _validationRules; }
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Loading…
Reference in New Issue