Files
linux-packaging-mono/external/aspnetwebstack/src/Microsoft.Web.Mvc/CopyAsyncParametersAttribute.cs
Jo Shields a575963da9 Imported Upstream version 3.6.0
Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
2014-08-13 10:39:27 +01:00

31 lines
1.0 KiB
C#

// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System;
using System.Web.Mvc;
using System.Web.Mvc.Async;
namespace Microsoft.Web.Mvc
{
[AttributeUsage(AttributeTargets.Class | AttributeTargets.Method, Inherited = true, AllowMultiple = false)]
public sealed class CopyAsyncParametersAttribute : ActionFilterAttribute
{
public override void OnActionExecuting(ActionExecutingContext filterContext)
{
if (filterContext == null)
{
throw new ArgumentNullException("filterContext");
}
IAsyncManagerContainer container = filterContext.Controller as IAsyncManagerContainer;
if (container != null)
{
AsyncManager asyncManager = container.AsyncManager;
foreach (var entry in filterContext.ActionParameters)
{
asyncManager.Parameters[entry.Key] = entry.Value;
}
}
}
}
}