代码位于卫浴IFormFile里的Headers(IHeaderDictionary)里,下面是两个接口的代码
new StringValues this[string key] { get; set; } 不懂这代码的写法,表达的意思,此代码位于IHeaderDictionary代码的最底部
IFormFile
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace Microsoft.AspNetCore.Http
{
//
// 摘要:
// Represents a file sent with the HttpRequest.
public interface IFormFile
{
//
// 摘要:
// Gets the raw Content-Disposition header of the uploaded file.
string ContentDisposition
{
get;
}
//
// 摘要:
// Gets the raw Content-Type header of the uploaded file.
string ContentType
{
get;
}
//
// 摘要:
// Gets the file name from the Content-Disposition header.
string FileName
{
get;
}
//
// 摘要:
// Gets the header dictionary of the uploaded file.
IHeaderDictionary Headers
{
get;
}
//
// 摘要:
// Gets the file length in bytes.
long Length
{
get;
}
//
// 摘要:
// Gets the form field name from the Content-Disposition header.
string Name
{
get;
}
//
// 摘要:
// Copies the contents of the uploaded file to the target stream.
//
// 参数:
// target:
// The stream to copy the file contents to.
void CopyTo(Stream target);
//
// 摘要:
// Asynchronously copies the contents of the uploaded file to the target stream.
//
// 参数:
// target:
// The stream to copy the file contents to.
//
// cancellationToken:
Task CopyToAsync(Stream target, CancellationToken cancellationToken = default(CancellationToken));
//
// 摘要:
// Opens the request stream for reading the uploaded file.
Stream OpenReadStream();
}
}
IHeaderDictionary
using Microsoft.Extensions.Primitives;
using System.Collections;
using System.Collections.Generic;
namespace Microsoft.AspNetCore.Http
{
//
// 摘要:
// Represents HttpRequest and HttpResponse headers
public interface IHeaderDictionary : ICollection<KeyValuePair<string, StringValues>>, IEnumerable<KeyValuePair<string, StringValues>>, IEnumerable, IDictionary<string, StringValues>
{
//
// 摘要:
// Strongly typed access to the Content-Length header. Implementations must keep
// this in sync with the string representation.
long? ContentLength
{
get;
set;
}
//
// 摘要:
// IHeaderDictionary has a different indexer contract than IDictionary, where it
// will return StringValues.Empty for missing entries.
//
// 参数:
// key:
//
// 返回结果:
// The stored value, or StringValues.Empty if the key is not present.
new StringValues this[string key]
{
get;
set;
}
}
}