Validating DataAnnotations


public static IList<String> GetClassLevelErrors(object instance){ return TypeDescriptor.GetAttributes(instance).OfType<ValidationAttribute>() .Where(attribute => !attribute.IsValid(instance)) .Select(attribute => attribute.FormatErrorMessage(string.Empty)) .ToList();}

[TestMethod]public void TestMethod1(){ var prop = typeof (DataAnnotationsModelBinderSpike.Models.Contact).GetProperty("First"); var attrib = prop.GetCustomAttributes(true).Cast<RequiredAttribute>().FirstOrDefault(); [...]

No related posts.

Base Controller Class and TempData


Need:
To pass information to every view based on an environmental variable. The specific case I ran across this need is when you want to use the minified version of your JavaScript libraries in production and the human readable in dev/QA.
Solution:

Create your own base controller class.
Override either onactionexecuting or onactionexecuted.
Populate TempData with the environment [...]

No related posts.

Help! Looking for a CSS DSL!

Update: Today Less CSS for .NET, or just .Less,  was released. Its a port of the ruby LESS library and exactly what I was/am looking for. I updated my question on SO already.
—– old post ——
I posted this on stackoverflow.com already…..
I’ve been working on a really large project for almost 2 years and the client [...]

No related posts.

First Day Thoughts: Valassis

Overall it was a very different day then the past 4 years. The day, to me, felt kind of weird but I think that’s just because I’ve become Pavlov’s dog. The absurd, obsessive strictness over trivial tasks/events/meetings/etc became common place. While it was, lets just say rough, to become trained (not broken), I don’t think [...]

No related posts.

Unrecognized attribute ‘targetFramework’

Change the app pool to target the .NET 4.0 Framework…it defaults to 2.

No related posts.

No related posts.