// Copyright (c) Microsoft Corporation. All rights reserved. See License.txt in the project root for license information.
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Diagnostics.CodeAnalysis;
using System.Linq;
using System.Net.Http;
using System.Net.Http.Formatting;
using System.Reflection;
using System.Threading.Tasks;
using System.Web.Http.Controllers;
namespace Microsoft.Web.Http.Data
{
///
/// This descriptor translates a direct CUD action invocation into a call to
/// Submit. This descriptor wraps the actual action, intercepting the execution
/// to do the transformation.
///
internal sealed class SubmitProxyActionDescriptor : ReflectedHttpActionDescriptor
{
private UpdateActionDescriptor _updateAction;
public SubmitProxyActionDescriptor(UpdateActionDescriptor updateAction)
: base(updateAction.ControllerDescriptor, updateAction.ControllerDescriptor.ControllerType.GetMethod("Submit", BindingFlags.Instance | BindingFlags.Public))
{
_updateAction = updateAction;
}
public override string ActionName
{
get { return _updateAction.ActionName; }
}
public override Type ReturnType
{
get { return typeof(HttpResponseMessage); }
}
public override Collection GetParameters()
{
return _updateAction.GetParameters();
}
[SuppressMessage("Microsoft.Reliability", "CA2000:Dispose objects before losing scope", Justification = "Caller is responsible for the lifetime of the object")]
public override Task