DCSIMG
January 2012 - Posts - Shimmy on .NET

January 2012 - Posts

2
Comments

Congratulations! We had a new babygirl! by Shimmy

Hi everyone! We just a had a very cute babygirl! Hope to post some photo any time soon...
תגים:
6
Comments

UniqueAttribute that validates a unique field against its fellow rows in the database (inherits DataAnnotations.ValidationAttribute) by Shimmy

UPDATE: Jan 30 2012 : Added check that entity is not itself (i.e. when user attempts to save the same entity). UPDATE: Feb 26 2012 : Added support for inherited entities, where the validated property is on the sub-class of the inheritance hierarchy. Here is a ValidationAttribute subclass that will allow you to validate that a column doesn't have duplicates. It's intended to be used with EF 4.1 DbContext , or with the EF4's ObjectContext . namespace System . ComponentModel . DataAnnotations...
2
Comments

Determine if char is Hebrew by Shimmy

Simple Ex. method: // avoid unicode chars in code private const char FirstHebChar = ( char )1488; //א private const char LastHebChar = ( char )1514; //ת private static bool IsHebrew ( this char c ) { return c >= FirstHebChar && c <= LastHebChar ; } Note: a comment bellow noted that the above function solely checks for hebrew characters within the א-ת range, it won't include punctuation marks, vowels or other biblical symbols. For a function that covers all (all that I'm aware...
תגים:, , , , ,
0
Comments

Enum.IsDefined for combined values not declared in the enum body by Shimmy

When you try to determine if an Enum value is defined in an Enum, it returns true only if the flags you've combined are explicitly declared in the Enum. Consider this Enum: [ Flags ] // Enum defined with a FlagsAttribute attribute. enum Hue : sbyte { Black = 0, //no color Red = 1, Green = 2, Blue = 4, Cyan = Green | Blue , //6 Magenta = Red | Blue , //5 BadColor = 127 } The following line will return false: var white = Hue . Red | Hue . Blue | Hue . Green ; //7 Even tho theoretically the enum...
תגים:,
Powered by Community Server (Commercial Edition), by Telligent Systems