protected void Application_Start() { RouteConfig.RegisterRoutes(RouteTable.Routes); HumanizedLabels.Register(); System.Web.Mvc.ModelBinders.Binders.Add(typeof(DateTime), new DateTimeModelBinder()); System.Web.Mvc.ModelBinders.Binders.Add(typeof(DateTime?), new DateTimeModelBinder()); }
public void Respect_explicit_display_name() { HumanizedLabels.Register(); var m = ModelMetadataProviders.Current.GetMetadataForProperty(null, typeof(NonHumanizedViewModel), "FieldWithDisplayNameAttribute"); Assert.That(m.DisplayName, Is.EqualTo("Existing display name")); }
public void Humanize_model_labels_with_custom_casing(LetterCasing casing, string expected) { HumanizedLabels.Register(casing); var m = ModelMetadataProviders.Current.GetMetadataForProperty(null, typeof(NonHumanizedViewModel), "SomeFieldName"); Assert.That(m.DisplayName, Is.EqualTo(expected)); }
public void Humanize_model_labels() { HumanizedLabels.Register(); var m = ModelMetadataProviders.Current.GetMetadataForProperty(null, typeof(NonHumanizedViewModel), "SomeFieldName"); Assert.That(m.DisplayName, Is.EqualTo("Some field name")); }
protected void Application_Start() { ContainerConfig.BuildContainer(); AreaRegistration.RegisterAllAreas(); FormTemplate.Default = new TwitterBootstrapFormTemplate(); HumanizedLabels.Register(); ModelBinders.Binders.Add(typeof(DateTime), new DateTimeModelBinder()); ModelBinders.Binders.Add(typeof(DateTime?), new DateTimeModelBinder()); }
protected void Application_Start() { RouteConfig.RegisterRoutes(RouteTable.Routes); HumanizedLabels.Register(); System.Web.Mvc.ModelBinders.Binders.Add(typeof(DateTime), new DateTimeModelBinder()); System.Web.Mvc.ModelBinders.Binders.Add(typeof(DateTime?), new DateTimeModelBinder()); DataAnnotationsModelValidatorProvider.RegisterAdapter(typeof(RequiredFlagsEnumAttribute), typeof(RequiredAttributeAdapter)); typeof(ExampleFormsController).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()); }); GlobalFilters.Filters.Add(new FormTemplateFilter()); }