Skip to content

Commit

Permalink
Merge pull request #144 from MRCollective/small-fixes
Browse files Browse the repository at this point in the history
Fixing some problems with the app start file
  • Loading branch information
robdmoore authored Jul 19, 2016
2 parents 15aaf85 + c3de397 commit 325225f
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
15 changes: 8 additions & 7 deletions AppStart.cs.pp
Original file line number Diff line number Diff line change
@@ -1,24 +1,25 @@
using ChameleonForms.Attributes;
using ChameleonForms.ModelBinders;
using System;
using System.Linq;
using System.Web.Mvc;

[assembly: WebActivator.PreApplicationStartMethod(typeof($rootnamespace$.App_Start.RegisterChameleonFormsComponents), "Start")]
[assembly: WebActivator.PreApplicationStartMethod(typeof($rootnamespace$.RegisterChameleonFormsComponents), "Start")]

namespace $rootnamespace$.App_Start
namespace $rootnamespace$
{
public static class RegisterChameleonFormsComponents
{
public static void Start()
{
System.Web.Mvc.ModelBinders.Binders.Add(typeof(DateTime), new DateTimeModelBinder());
System.Web.Mvc.ModelBinders.Binders.Add(typeof(DateTime?), new DateTimeModelBinder());
ModelBinders.Binders.Add(typeof(DateTime), new DateTimeModelBinder());
ModelBinders.Binders.Add(typeof(DateTime?), new DateTimeModelBinder());
DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredFlagsEnumAttribute), typeof(RequiredAttributeAdapter));
GetType().Assembly.GetTypes().Where(t => t.IsEnum && t.GetCustomAttributes(typeof(FlagsAttribute), false).Any())
typeof(RegisterChameleonFormsComponents).Assembly.GetTypes().Where(t => t.IsEnum && t.GetCustomAttributes(typeof(FlagsAttribute), false).Any())
.ToList().ForEach(t =>
{
System.Web.Mvc.ModelBinders.Binders.Add(t, new FlagsEnumModelBinder());
System.Web.Mvc.ModelBinders.Binders.Add(typeof(Nullable<>).MakeGenericType(t), new FlagsEnumModelBinder());
ModelBinders.Binders.Add(t, new FlagsEnumModelBinder());
ModelBinders.Binders.Add(typeof(Nullable<>).MakeGenericType(t), new FlagsEnumModelBinder());
});
}
}
Expand Down
2 changes: 1 addition & 1 deletion ChameleonForms/readme.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ ChameleonForms
* For the project homepage including the current README, see https://github.com/MRCollective/ChameleonForms
* To check for potential breaking changes in this release, see https://github.com/MRCollective/ChameleonForms/blob/master/BREAKING_CHANGES.md
* If you need to raise an issue or check for an existing issue, see https://github.com/MRCollective/ChameleonForms/issues
* To consult the ChameleonForms documentation, see https://github.com/MRCollective/ChameleonForms/wiki
* To consult the ChameleonForms documentation, see https://chameleonforms.readthedocs.io/

0 comments on commit 325225f

Please sign in to comment.