* Web.csproj:
* Profile.aspx: * MyProfile.aspx: * AccountController.cs: renamed the Profile method to "MyProfile", could avoid issue at migrating to MVC5 * favicon.png: favicon now displays a ~"Yavsc" * BlogManager.cs: * BlogsApiController.cs: The authorisation for removing a post is now implemented at Manager's side * BlogsController.cs: Removes this odd call to a static method from the Api controller * CalendarApi.cs: * GoogleController.cs: no more json output for the calls to the Google Api * WorkFlowController.cs: sorted using clauses * Basket.cs: * Commande.cs: * EstimToPdfFormatter.cs: * Brand.cs: adds xml doc * RssFeedsFormatter.cs: modifies xml doc * TexToPdfFormatter.cs: refactoring * Global.asax.cs: Document formatting * BBCodeHelper.cs: encapsulates the url display from the BBCode in starting and closing characters : "<>" * OAuth2.cs: * SimpleJsonPostMethod.cs: using System.Runtime.Serialization.Json instead of Newtonsof.Json * App.master: updating the favicon * RegistrationPending.aspx: fixes the returnUrl usage * AssemblyInfo.aspx: better explanation for this list * Web.config: tried to migrate to MVC5 (using NuGets) * Estim.cs: * ChangePasswordModel.cs: adds xmldoc * BasketController.cs: * BlogProvidersConfigurationSection.cs: cosmetic change * GoogleErrorMessage.cs: - adds xml docs - renders ctor from JsonReaderException obsolete * MvcActionValueBinder.cs: not used * web.config: no more used, gave it up to migrate to MVC5vnext
parent
a342b744df
commit
e676d2fdbf
@ -1,97 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Collections.Specialized;
|
||||
using System.Globalization;
|
||||
using System.Linq;
|
||||
using System.Net.Http;
|
||||
using System.Net.Http.Formatting;
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Web.Http;
|
||||
using System.Web.Http.Controllers;
|
||||
using System.Web.Http.ModelBinding;
|
||||
using System.Web.Http.ValueProviders;
|
||||
using System.Web.Http.ValueProviders.Providers;
|
||||
|
||||
namespace Basic
|
||||
{
|
||||
// Binder with MVC semantics. Treat the body as KeyValue pairs and model bind it.
|
||||
/// <summary>
|
||||
/// Mvc action value binder.
|
||||
/// </summary>
|
||||
public class MvcActionValueBinder : DefaultActionValueBinder
|
||||
{
|
||||
// Per-request storage, uses the Request.Properties bag. We need a unique key into the bag.
|
||||
private const string Key = "5DC187FB-BFA0-462A-AB93-9E8036871EC8";
|
||||
|
||||
/// <summary>
|
||||
/// Gets the binding.
|
||||
/// </summary>
|
||||
/// <returns>The binding.</returns>
|
||||
/// <param name="actionDescriptor">Action descriptor.</param>
|
||||
public override HttpActionBinding GetBinding (HttpActionDescriptor actionDescriptor)
|
||||
{
|
||||
|
||||
HttpActionBinding actionBinding = new HttpActionBinding ();
|
||||
|
||||
HttpParameterDescriptor[] parameters = actionDescriptor.GetParameters ().ToArray ();
|
||||
HttpParameterBinding[] binders = Array.ConvertAll (parameters, p => DetermineBinding (actionBinding, p));
|
||||
|
||||
actionBinding.ParameterBindings = binders;
|
||||
return actionBinding;
|
||||
}
|
||||
|
||||
private HttpParameterBinding DetermineBinding (HttpActionBinding actionBinding, HttpParameterDescriptor parameter)
|
||||
{
|
||||
HttpConfiguration config = parameter.Configuration;
|
||||
|
||||
var attr = new ModelBinderAttribute(); // use default settings
|
||||
|
||||
ModelBinderProvider provider = attr.GetModelBinderProvider(config);
|
||||
|
||||
// Alternatively, we could put this ValueProviderFactory in the global config.
|
||||
List<ValueProviderFactory> vpfs = new List<ValueProviderFactory>(attr.GetValueProviderFactories(config));
|
||||
vpfs.Add(new BodyValueProviderFactory());
|
||||
//vpfs.Add (new RouteDataValueProviderFactory ());
|
||||
return new ModelBinderParameterBinding(parameter, provider, vpfs);
|
||||
}
|
||||
|
||||
// Derive from ActionBinding so that we have a chance to read the body once and then share that with all the parameters.
|
||||
private class MvcActionBinding : HttpActionBinding
|
||||
{
|
||||
// Read the body upfront , add as a ValueProvider
|
||||
public override Task ExecuteBindingAsync (HttpActionContext actionContext, CancellationToken cancellationToken)
|
||||
{
|
||||
HttpRequestMessage request = actionContext.ControllerContext.Request;
|
||||
HttpContent content = request.Content;
|
||||
if (content != null) {
|
||||
// content.ReadAsStreamAsync ().Result;
|
||||
FormDataCollection fd = content.ReadAsAsync<FormDataCollection> ().Result;
|
||||
if (fd != null) {
|
||||
|
||||
NameValueCollection nvc = fd.ReadAsNameValueCollection ();
|
||||
|
||||
System.Web.Http.ValueProviders.IValueProvider vp = new System.Web.Http.ValueProviders.Providers.NameValueCollectionValueProvider (nvc, CultureInfo.InvariantCulture);
|
||||
|
||||
request.Properties.Add (Key, vp);
|
||||
}
|
||||
}
|
||||
|
||||
return base.ExecuteBindingAsync (actionContext, cancellationToken);
|
||||
}
|
||||
}
|
||||
// Get a value provider over the body. This can be shared by all parameters.
|
||||
// This gets the values computed in MvcActionBinding.
|
||||
private class BodyValueProviderFactory : System.Web.Http.ValueProviders.ValueProviderFactory
|
||||
{
|
||||
public override System.Web.Http.ValueProviders.IValueProvider GetValueProvider (HttpActionContext actionContext)
|
||||
{
|
||||
object vp;
|
||||
actionContext.Request.Properties.TryGetValue (Key, out vp);
|
||||
return (System.Web.Http.ValueProviders.IValueProvider)vp; // can be null
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Binary file not shown.
Before Width: | Height: | Size: 3.2 KiB After Width: | Height: | Size: 3.4 KiB |
@ -1,3 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<configuration>
|
||||
</configuration>
|
Loading…
Reference in New Issue