summaryrefslogtreecommitdiffstats
path: root/src/DotNetOpenAuth.Core/Messaging/MessageProtectionTasks.cs
blob: 37c86ca3ebfb9e4a4f55096bc592b1848423243c (plain)
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
//-----------------------------------------------------------------------
// <copyright file="MessageProtectionTasks.cs" company="Andrew Arnott">
//     Copyright (c) Andrew Arnott. All rights reserved.
// </copyright>
//-----------------------------------------------------------------------

namespace DotNetOpenAuth.Messaging {
	using System;
	using System.Collections.Generic;
	using System.Linq;
	using System.Text;
	using System.Threading.Tasks;

	/// <summary>
	/// Reusable pre-completed tasks that may be returned multiple times to reduce GC pressure.
	/// </summary>
	internal static class MessageProtectionTasks {
		/// <summary>
		/// A task whose result is <c>null</c>
		/// </summary>
		internal static readonly Task<MessageProtections?> Null = Task.FromResult<MessageProtections?>(null);

		/// <summary>
		/// A task whose result is <see cref="MessageProtections.None"/>
		/// </summary>
		internal static readonly Task<MessageProtections?> None =
			Task.FromResult<MessageProtections?>(MessageProtections.None);

		/// <summary>
		/// A task whose result is <see cref="MessageProtections.TamperProtection"/>
		/// </summary>
		internal static readonly Task<MessageProtections?> TamperProtection =
			Task.FromResult<MessageProtections?>(MessageProtections.TamperProtection);

		/// <summary>
		/// A task whose result is <see cref="MessageProtections.ReplayProtection"/>
		/// </summary>
		internal static readonly Task<MessageProtections?> ReplayProtection =
			Task.FromResult<MessageProtections?>(MessageProtections.ReplayProtection);
	}
}