This repository has been archived by the owner on Jan 15, 2021. It is now read-only.
/
ModelBindingModel.cs
75 lines (59 loc) · 2.1 KB
/
ModelBindingModel.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using Glimpse.Mvc.AlternateType;
namespace Glimpse.Mvc.Model
{
public class ModelBindingModel
{
public ModelBindingModel(string parameter)
{
ParameterName = parameter;
ValueProviderActivity = new List<ValueProviderModel>();
Properties = new List<ModelBindingModel>();
IsBound = false;
}
public string ParameterName { get; private set; }
public Type ParameterType { get; set; }
public Type ModelBinderType { get; set; }
public CultureInfo Culture { get; set; }
public string AttemptedValue { get; set; }
public object RawValue { get; set; }
public IList<ModelBindingModel> Properties { get; set; }
public IList<ValueProviderModel> ValueProviderActivity { get; set; }
internal bool IsBound { get; set; }
public void Add<T>(ValueProvider<T>.ContainsPrefix.Message message) where T : class
{
if (!ValueProviderActivity.Any(vp => vp.IsMatch))
{
ValueProviderActivity.Add(new ValueProviderModel(message.ValueProviderType, message.IsMatch));
}
}
public void Add<T>(ValueProvider<T>.GetValue.Message message) where T : class
{
if (message.IsFound)
{
AttemptedValue = message.AttemptedValue;
Culture = message.Culture;
}
}
public void Bound(ModelBinder.BindModel.Message message)
{
ModelBinderType = message.ModelBinderType;
ParameterType = message.ModelType;
RawValue = message.RawValue;
IsBound = true;
}
public class ValueProviderModel
{
public ValueProviderModel(Type valueProvider, bool isMatch)
{
ValueProvider = valueProvider;
IsMatch = isMatch;
}
public Type ValueProvider { get; set; }
public bool IsMatch { get; set; }
}
}
}