|
|
@@ -797,6 +797,12 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|
|
/// <inheritdoc />
|
|
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// <para>
|
|
|
+ /// This API supports the MVC's infrastructure and is not intended to be used
|
|
|
+ /// directly from your code. This API may change or be removed in future releases.
|
|
|
+ /// </para>
|
|
|
+ /// </summary>
|
|
|
public static bool StartsWithPrefix(string prefix, string key)
|
|
|
{
|
|
|
if (prefix == null)
|
|
|
@@ -840,6 +846,12 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Gets a <see cref="PrefixEnumerable"/> that iterates over this instance of <see cref="ModelStateDictionary"/>
|
|
|
+ /// using the specified <paramref name="prefix"/>.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="prefix">The prefix.</param>
|
|
|
+ /// <returns>The <see cref="PrefixEnumerable"/>.</returns>
|
|
|
public PrefixEnumerable FindKeysWithPrefix(string prefix)
|
|
|
{
|
|
|
if (prefix == null)
|
|
|
@@ -1004,11 +1016,20 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Enumerates over <see cref="ModelStateDictionary"/> to provide entries that start with the
|
|
|
+ /// specified prefix.
|
|
|
+ /// </summary>
|
|
|
public readonly struct PrefixEnumerable : IEnumerable<KeyValuePair<string, ModelStateEntry>>
|
|
|
{
|
|
|
private readonly ModelStateDictionary _dictionary;
|
|
|
private readonly string _prefix;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Initializes a new instance of <see cref="PrefixEnumerable"/>.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dictionary">The <see cref="ModelStateDictionary"/>.</param>
|
|
|
+ /// <param name="prefix">The prefix.</param>
|
|
|
public PrefixEnumerable(ModelStateDictionary dictionary, string prefix)
|
|
|
{
|
|
|
if (dictionary == null)
|
|
|
@@ -1025,6 +1046,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|
|
_prefix = prefix;
|
|
|
}
|
|
|
|
|
|
+ /// <inheritdoc />
|
|
|
public Enumerator GetEnumerator() => new Enumerator(_dictionary, _prefix);
|
|
|
|
|
|
IEnumerator<KeyValuePair<string, ModelStateEntry>>
|
|
|
@@ -1033,6 +1055,9 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// An <see cref="IEnumerator{T}"/> for <see cref="PrefixEnumerable"/>.
|
|
|
+ /// </summary>
|
|
|
public struct Enumerator : IEnumerator<KeyValuePair<string, ModelStateEntry>>
|
|
|
{
|
|
|
private readonly ModelStateNode _rootNode;
|
|
|
@@ -1041,6 +1066,11 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|
|
private int _index;
|
|
|
private bool _visitedRoot;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Intializes a new instance of <see cref="Enumerator"/>.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dictionary">The <see cref="ModelStateDictionary"/>.</param>
|
|
|
+ /// <param name="prefix">The prefix.</param>
|
|
|
public Enumerator(ModelStateDictionary dictionary, string prefix)
|
|
|
{
|
|
|
if (dictionary == null)
|
|
|
@@ -1059,16 +1089,19 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|
|
_nodes = null;
|
|
|
_visitedRoot = false;
|
|
|
}
|
|
|
-
|
|
|
+
|
|
|
+ /// <inheritdoc />
|
|
|
public KeyValuePair<string, ModelStateEntry> Current =>
|
|
|
new KeyValuePair<string, ModelStateEntry>(_modelStateNode.Key, _modelStateNode);
|
|
|
|
|
|
object IEnumerator.Current => Current;
|
|
|
|
|
|
+ /// <inheritdoc />
|
|
|
public void Dispose()
|
|
|
{
|
|
|
}
|
|
|
|
|
|
+ /// <inheritdoc />
|
|
|
public bool MoveNext()
|
|
|
{
|
|
|
if (_rootNode == null)
|
|
|
@@ -1128,6 +1161,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|
|
return false;
|
|
|
}
|
|
|
|
|
|
+ /// <inheritdoc />
|
|
|
public void Reset()
|
|
|
{
|
|
|
_index = -1;
|
|
|
@@ -1137,15 +1171,23 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// A <see cref="IEnumerable{T}"/> for keys in <see cref="ModelStateDictionary"/>.
|
|
|
+ /// </summary>
|
|
|
public readonly struct KeyEnumerable : IEnumerable<string>
|
|
|
{
|
|
|
private readonly ModelStateDictionary _dictionary;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Initializes a new instance of <see cref="KeyEnumerable"/>.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dictionary">The <see cref="ModelStateDictionary"/>.</param>
|
|
|
public KeyEnumerable(ModelStateDictionary dictionary)
|
|
|
{
|
|
|
_dictionary = dictionary;
|
|
|
}
|
|
|
|
|
|
+ /// <inheritdoc />
|
|
|
public KeyEnumerator GetEnumerator() => new KeyEnumerator(_dictionary, prefix: string.Empty);
|
|
|
|
|
|
IEnumerator<string> IEnumerable<string>.GetEnumerator() => GetEnumerator();
|
|
|
@@ -1153,22 +1195,33 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// An <see cref="IEnumerator{T}"/> for keys in <see cref="ModelStateDictionary"/>.
|
|
|
+ /// </summary>
|
|
|
public struct KeyEnumerator : IEnumerator<string>
|
|
|
{
|
|
|
private Enumerator _prefixEnumerator;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Initializes a new instance of <see cref="KeyEnumerable"/>.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dictionary">The <see cref="ModelStateDictionary"/>.</param>
|
|
|
+ /// <param name="prefix">The prefix.</param>
|
|
|
public KeyEnumerator(ModelStateDictionary dictionary, string prefix)
|
|
|
{
|
|
|
_prefixEnumerator = new Enumerator(dictionary, prefix);
|
|
|
Current = null;
|
|
|
}
|
|
|
|
|
|
+ /// <inheritdoc />
|
|
|
public string Current { get; private set; }
|
|
|
|
|
|
object IEnumerator.Current => Current;
|
|
|
|
|
|
+ /// <inheritdoc />
|
|
|
public void Dispose() => _prefixEnumerator.Dispose();
|
|
|
|
|
|
+ /// <inheritdoc />
|
|
|
public bool MoveNext()
|
|
|
{
|
|
|
var result = _prefixEnumerator.MoveNext();
|
|
|
@@ -1185,6 +1238,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /// <inheritdoc />
|
|
|
public void Reset()
|
|
|
{
|
|
|
_prefixEnumerator.Reset();
|
|
|
@@ -1192,15 +1246,23 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// An <see cref="IEnumerable"/> for <see cref="ModelStateEntry"/>.
|
|
|
+ /// </summary>
|
|
|
public readonly struct ValueEnumerable : IEnumerable<ModelStateEntry>
|
|
|
{
|
|
|
private readonly ModelStateDictionary _dictionary;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Initializes a new instance of <see cref="ValueEnumerable"/>.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dictionary">The <see cref="ModelStateDictionary"/>.</param>
|
|
|
public ValueEnumerable(ModelStateDictionary dictionary)
|
|
|
{
|
|
|
_dictionary = dictionary;
|
|
|
}
|
|
|
|
|
|
+ /// <inheritdoc />
|
|
|
public ValueEnumerator GetEnumerator() => new ValueEnumerator(_dictionary, prefix: string.Empty);
|
|
|
|
|
|
IEnumerator<ModelStateEntry> IEnumerable<ModelStateEntry>.GetEnumerator() => GetEnumerator();
|
|
|
@@ -1208,22 +1270,33 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|
|
IEnumerator IEnumerable.GetEnumerator() => GetEnumerator();
|
|
|
}
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// An enumerator for <see cref="ModelStateEntry"/>.
|
|
|
+ /// </summary>
|
|
|
public struct ValueEnumerator : IEnumerator<ModelStateEntry>
|
|
|
{
|
|
|
private Enumerator _prefixEnumerator;
|
|
|
|
|
|
+ /// <summary>
|
|
|
+ /// Initializes a new instance of <see cref="ValueEnumerator"/>.
|
|
|
+ /// </summary>
|
|
|
+ /// <param name="dictionary">The <see cref="ModelStateDictionary"/>.</param>
|
|
|
+ /// <param name="prefix">The prefix to enumerate.</param>
|
|
|
public ValueEnumerator(ModelStateDictionary dictionary, string prefix)
|
|
|
{
|
|
|
_prefixEnumerator = new Enumerator(dictionary, prefix);
|
|
|
Current = null;
|
|
|
}
|
|
|
|
|
|
+ /// <inheritdoc />
|
|
|
public ModelStateEntry Current { get; private set; }
|
|
|
|
|
|
object IEnumerator.Current => Current;
|
|
|
|
|
|
+ /// <inheritdoc />
|
|
|
public void Dispose() => _prefixEnumerator.Dispose();
|
|
|
|
|
|
+ /// <inheritdoc />
|
|
|
public bool MoveNext()
|
|
|
{
|
|
|
var result = _prefixEnumerator.MoveNext();
|
|
|
@@ -1240,6 +1313,7 @@ namespace Microsoft.AspNetCore.Mvc.ModelBinding
|
|
|
return result;
|
|
|
}
|
|
|
|
|
|
+ /// <inheritdoc />
|
|
|
public void Reset()
|
|
|
{
|
|
|
_prefixEnumerator.Reset();
|