Added hammock project to debug streaming issues
[pithos-ms-client] / trunk / hammock / src / net35 / Hammock / Attributes / Validation / BooleanToIntegerAttribute.cs
1 using System;
2 using System.Reflection;
3
4 namespace Hammock.Attributes.Validation
5 {
6 #if !SILVERLIGHT
7     [Serializable]
8 #endif
9     public class BooleanToIntegerAttribute : ValidationAttribute
10     {
11         public override string TransformValue(PropertyInfo property, object value)
12       {
13 #if !Smartphone && !NETCF
14             bool result;
15             return bool.TryParse(value.ToString(), out result)
16                        ? result ? "1" : "0"
17                        : base.TransformValue(property, value);
18 #else
19         try
20             {
21                 var result = bool.Parse(value.ToString());
22                 return result ? "1" : "0";
23             }
24             catch (Exception)
25             {
26                 return base.TransformValue(property, value);
27             }
28 #endif
29         }
30     }
31 }