forked from TestStack/TestStack.Seleno
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathRegisterChameleonFormsComponents.cs
More file actions
26 lines (24 loc) · 1.14 KB
/
Copy pathRegisterChameleonFormsComponents.cs
File metadata and controls
26 lines (24 loc) · 1.14 KB
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
using ChameleonForms.Attributes;
using ChameleonForms.ModelBinders;
using System;
using System.Linq;
using System.Web.Mvc;
[assembly: WebActivator.PreApplicationStartMethod(typeof(TestStack.Seleno.AcceptanceTests.Web.RegisterChameleonFormsComponents), "Start")]
namespace TestStack.Seleno.AcceptanceTests.Web
{
public static class RegisterChameleonFormsComponents
{
public static void Start()
{
ModelBinders.Binders.Add(typeof(DateTime), new DateTimeModelBinder());
ModelBinders.Binders.Add(typeof(DateTime?), new DateTimeModelBinder());
DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredFlagsEnumAttribute), typeof(RequiredAttributeAdapter));
typeof(RegisterChameleonFormsComponents).Assembly.GetTypes().Where(t => t.IsEnum && t.GetCustomAttributes(typeof(FlagsAttribute), false).Any())
.ToList().ForEach(t =>
{
ModelBinders.Binders.Add(t, new FlagsEnumModelBinder());
ModelBinders.Binders.Add(typeof(Nullable<>).MakeGenericType(t), new FlagsEnumModelBinder());
});
}
}
}