/
IFeatureCollection.cs
44 lines (37 loc) · 1.43 KB
/
IFeatureCollection.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
using System;
using System.Collections.Generic;
namespace Microsoft.AspNetCore.Http.Features;
/// <summary>
/// Represents a collection of HTTP features.
/// </summary>
public interface IFeatureCollection : IEnumerable<KeyValuePair<Type, object>>
{
/// <summary>
/// Indicates if the collection can be modified.
/// </summary>
bool IsReadOnly { get; }
/// <summary>
/// Incremented for each modification and can be used to verify cached results.
/// </summary>
int Revision { get; }
/// <summary>
/// Gets or sets a given feature. Setting a null value removes the feature.
/// </summary>
/// <param name="key"></param>
/// <returns>The requested feature, or null if it is not present.</returns>
object? this[Type key] { get; set; }
/// <summary>
/// Retrieves the requested feature from the collection.
/// </summary>
/// <typeparam name="TFeature">The feature key.</typeparam>
/// <returns>The requested feature, or null if it is not present.</returns>
TFeature? Get<TFeature>();
/// <summary>
/// Sets the given feature in the collection.
/// </summary>
/// <typeparam name="TFeature">The feature key.</typeparam>
/// <param name="instance">The feature value.</param>
void Set<TFeature>(TFeature? instance);
}