forked from aspnet/AspNetWebStack
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCancellationTokenParameterBinding.cs
More file actions
28 lines (25 loc) · 991 Bytes
/
Copy pathCancellationTokenParameterBinding.cs
File metadata and controls
28 lines (25 loc) · 991 Bytes
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
// Copyright (c) .NET Foundation. All rights reserved.
// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.
using System.Threading;
using System.Threading.Tasks;
using System.Web.Http.Controllers;
using System.Web.Http.Metadata;
namespace System.Web.Http.ModelBinding
{
/// <summary>
/// Bind directly to the cancellation token
/// </summary>
public class CancellationTokenParameterBinding : HttpParameterBinding
{
public CancellationTokenParameterBinding(HttpParameterDescriptor descriptor)
: base(descriptor)
{
}
public override Task ExecuteBindingAsync(ModelMetadataProvider metadataProvider, HttpActionContext actionContext, CancellationToken cancellationToken)
{
string name = Descriptor.ParameterName;
actionContext.ActionArguments.Add(name, cancellationToken);
return TaskHelpers.Completed();
}
}
}