billbogaiv/hybrid-model-binding

Rename IsUnsafe to Behavior

khalidabuhakmeh opened this issue · 1 comments

Since IsUnsafe sounds scary and not exactly what you want to portray to users of this library, I propose we change the property to Behavior.

using HybridModelBinding;
using Microsoft.AspNetCore.Mvc;

public class Person
{
    // Will continue to Bind through to Route
    // only keeping a non-null value in the Property
    [From(QueryString, Route, Behavior = Behavior.Last)]
    public int Age { get; set; }

    // Will bind on the first non-null value
    // and then stop.
    [From(Route, Body, Behavior = Behavior.First)]
    public string Name { get; set; }
}

The default behavior should be First, which will work even for one provider.

Took a different strategy to allow implementer-derived binding-behavior. There are two sane defaults which should cover the majority of expectations.