StructModelBinder<TModel> Class
Abstract base class for custom model binders that bind a struct of type TModel from a single value using TryParse(string).
public abstract class StructModelBinder<TModel> : HAKOM.Serialization.Http.Net.Api.ICustomModelBinder, Microsoft.AspNetCore.Mvc.ModelBinding.IModelBinder where TModel : struct, System.ValueType, System.ValueTypeType parameters
Section titled “Type parameters”TModel
The struct type to bind.
Inheritance System.Object 🡒 StructModelBinder<TModel>
Implements ICustomModelBinder, Microsoft.AspNetCore.Mvc.ModelBinding.IModelBinder
Methods
Section titled “Methods”StructModelBinder<TModel>.BindModelAsync(ModelBindingContext) Method
Section titled “StructModelBinder<TModel>.BindModelAsync(ModelBindingContext) Method”public System.Threading.Tasks.Task BindModelAsync(Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext bindingContext);Parameters
Section titled “Parameters”bindingContext Microsoft.AspNetCore.Mvc.ModelBinding.ModelBindingContext
Implements BindModelAsync(ModelBindingContext)
Returns
Section titled “Returns”StructModelBinder<TModel>.CanBind(Type, BindingSource) Method
Section titled “StructModelBinder<TModel>.CanBind(Type, BindingSource) Method”Determines whether this binder can bind the specified modelType from the given bindingSource.
public virtual bool CanBind(System.Type modelType, Microsoft.AspNetCore.Mvc.ModelBinding.BindingSource? bindingSource);Parameters
Section titled “Parameters”modelType System.Type
The System.Type of the model to bind.
bindingSource Microsoft.AspNetCore.Mvc.ModelBinding.BindingSource
The Microsoft.AspNetCore.Mvc.ModelBinding.BindingSource indicating where the data originates, or null.
Implements CanBind(Type, BindingSource)
Returns
Section titled “Returns”System.Boolean
true if this binder supports the specified model type and binding source; otherwise, false.
StructModelBinder<TModel>.TryParse(string) Method
Section titled “StructModelBinder<TModel>.TryParse(string) Method”Attempts to parse the specified string value into an instance of TModel.
protected abstract HAKOM.ErrorHandling.Core.Net.Api.Result<TModel> TryParse(string value);Parameters
Section titled “Parameters”value System.String
The string value to parse.
Returns
Section titled “Returns”HAKOM.ErrorHandling.Core.Net.Api.Result<TModel>
A Result<TValue> containing the parsed model on success, or an error on failure.