{"id":16184632,"url":"https://github.com/rmariuzzo/mariuzzo.web.mvc.extras","last_synced_at":"2025-04-10T05:24:51.409Z","repository":{"id":7037417,"uuid":"8313642","full_name":"rmariuzzo/Mariuzzo.Web.Mvc.Extras","owner":"rmariuzzo","description":"Extra missing components for ASP.NET MVC.","archived":false,"fork":false,"pushed_at":"2016-08-01T15:13:57.000Z","size":24,"stargazers_count":4,"open_issues_count":1,"forks_count":0,"subscribers_count":2,"default_branch":"master","last_synced_at":"2025-04-09T20:15:28.549Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"","language":"C#","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/rmariuzzo.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2013-02-20T13:31:44.000Z","updated_at":"2020-02-25T02:06:56.000Z","dependencies_parsed_at":"2022-09-22T11:30:30.569Z","dependency_job_id":null,"html_url":"https://github.com/rmariuzzo/Mariuzzo.Web.Mvc.Extras","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmariuzzo%2FMariuzzo.Web.Mvc.Extras","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmariuzzo%2FMariuzzo.Web.Mvc.Extras/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmariuzzo%2FMariuzzo.Web.Mvc.Extras/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/rmariuzzo%2FMariuzzo.Web.Mvc.Extras/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/rmariuzzo","download_url":"https://codeload.github.com/rmariuzzo/Mariuzzo.Web.Mvc.Extras/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":248161873,"owners_count":21057664,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-10-10T07:10:52.879Z","updated_at":"2025-04-10T05:24:51.390Z","avatar_url":"https://github.com/rmariuzzo.png","language":"C#","funding_links":[],"categories":[],"sub_categories":[],"readme":"Mariuzzo.Web.Mvc.Extras\n=======================\n\nExtra missing components for ASP.NET MVC.\n\nInstallation\n------------\n\nTo install [Mariuzzo.Web.Mvc.Extras](http://nuget.org/packages/Mariuzzo.Web.Mvc.Extras/), run the following command in the NuGet's [Package Manager Console](http://docs.nuget.org/docs/start-here/using-the-package-manager-console)\n\n```shell\nInstall-Package Mariuzzo.Web.Mvc.Extras\n```\n\nDocumentation\n=============\n\nExpressionHelper\n----------------\n\n##### GetExpressionText\n\nWhat is inside the Extras?\n--------------------------\n\n - [ExpressionHelper](#expressionhelper).\n - [ModelStateDictionaryExtensions](#modelstatedictionaryextensions)\n\nExpressionHelper\n----------------\n\nA better `ExpressionHelper` class that properly handles `UnaryExpression` (aka Convert expression).\n\n### How to use ###\n\nOn any code block just call the static methods: `Mariuzzo.Web.Mvc.Extras.ExpressionHelper.GetExpressionText(...)`.\n\n### The Problem ###\n\nThe [`System.Web.Mvc.ExpressionHelper#GetExpressionText`](http://msdn.microsoft.com/en-us/library/ee428394.aspx) return an empty string for any [`Nullable`](http://msdn.microsoft.com/en-us/library/b3h38hb0.aspx) property. \n\nIf you have the following `Foo` class:\n\n```csharp\nclass Foo {\n\tpublic int? Id { get; set; }\n}\n```\n\nAnd then run: `System.Web.Mvc.ExpressionHelper.GetExpressionText((Foo f) =\u003e f.Id)` you will receive an empty string instead of: `Id`. The same goes for any inner property that are [`Nullable`](http://msdn.microsoft.com/en-us/library/b3h38hb0.aspx).\n\n### Solution ###\n\nThe [`Mariuzzo.Web.Mvc.Extras.ExpressionHelper`](https://github.com/rmariuzzo/Mariuzzo.Web.Mvc.Extras/blob/master/Mariuzzo.Web.Mvc.Extras/ExpressionHelper.cs) provides a `GetExpressionText` method that handle that specific case.\n\nModelStateDictionaryExtensions\n------------------------------\n\nSet of extension methods for [ModelStateDictionary](http://msdn.microsoft.com/en-us/library/system.web.mvc.modelstatedictionary.aspx) providing methods supporting Lambda Expression instead of _magic string_.\n\n### How to use ###\n\nOn top of any of your Controllers just add: `using Mariuzzo.Web.Mvc.Extras;`.\n\n### The Problem ###\n\nWhat would happen to the following code if you rename the property `Bar` of your model?\n\n```csharp\nif (ModelState.IsValidField(\"Bar\")\n{\n\t...\n}\n```\n\nIf you forgot to also rename any of those _magic string_, I'm pretty sure you and your controllers will be in problem.\n\n### Solution ###\n\nThe [`Mariuzzo.Web.Mvc.Extras.ModelStateDictionaryExtensions`](https://github.com/rmariuzzo/Mariuzzo.Web.Mvc.Extras/blob/master/Mariuzzo.Web.Mvc.Extras/ModelStateDictionaryExtensions.cs) extend the legacy [ModelStateDictionary](http://msdn.microsoft.com/en-us/library/system.web.mvc.modelstatedictionary.aspx) and provides the same methods, but instead of _magic strings_ it accepts Lambda Expression.\n\n```csharp\nif (ModelState.IsValidField((Foo f) =\u003e f.Bar))\n{\n\t...\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmariuzzo%2Fmariuzzo.web.mvc.extras","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Frmariuzzo%2Fmariuzzo.web.mvc.extras","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Frmariuzzo%2Fmariuzzo.web.mvc.extras/lists"}