parent
2422138ab4
commit
cbed7393a2
|
|
@ -10,10 +10,33 @@ namespace Microsoft.AspNetCore.Http
|
|||
/// </summary>
|
||||
public interface IFormFileCollection : IReadOnlyList<IFormFile>
|
||||
{
|
||||
/// <summary>
|
||||
/// Gets the file with the specified name.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the file to get.</param>
|
||||
/// <returns>
|
||||
/// The requested file, or null if it is not present.
|
||||
/// </returns>
|
||||
IFormFile this[string name] { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the file with the specified name.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the file to get.</param>
|
||||
/// <returns>
|
||||
/// The requested file, or null if it is not present.
|
||||
/// </returns>
|
||||
IFormFile GetFile(string name);
|
||||
|
||||
/// <summary>
|
||||
/// Gets an <see cref="IReadOnlyList{T}" /> containing the files of the
|
||||
/// <see cref="IFormFileCollection" /> with the specified name.
|
||||
/// </summary>
|
||||
/// <param name="name">The name of the files to get.</param>
|
||||
/// <returns>
|
||||
/// An <see cref="IReadOnlyList{T}" /> containing the files of the object
|
||||
/// that implements <see cref="IFormFileCollection" />.
|
||||
/// </returns>
|
||||
IReadOnlyList<IFormFile> GetFiles(string name);
|
||||
}
|
||||
}
|
||||
|
|
@ -6,10 +6,15 @@ using System.Collections.Generic;
|
|||
|
||||
namespace Microsoft.AspNetCore.Http.Internal
|
||||
{
|
||||
/// <summary>
|
||||
/// Default implementation of <see cref="IFormFileCollection"/>.
|
||||
/// </summary>
|
||||
public class FormFileCollection : List<IFormFile>, IFormFileCollection
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public IFormFile this[string name] => GetFile(name);
|
||||
|
||||
/// <inheritdoc />
|
||||
public IFormFile GetFile(string name)
|
||||
{
|
||||
foreach (var file in this)
|
||||
|
|
@ -23,6 +28,7 @@ namespace Microsoft.AspNetCore.Http.Internal
|
|||
return null;
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
public IReadOnlyList<IFormFile> GetFiles(string name)
|
||||
{
|
||||
var files = new List<IFormFile>();
|
||||
|
|
|
|||
Loading…
Reference in New Issue