C# Client Library
A C# Client Library for the AnalyzeRe REST API
Loading...
Searching...
No Matches
NumericValidationAttribute.cs
Go to the documentation of this file.
1using System;
3
5{
7 [AttributeUsage(AttributeTargets.Property, Inherited = true, AllowMultiple = true)]
9 {
15 protected double GetValue(object value)
16 {
17 try
18 {
19 if (value is MonetaryUnit)
20 return ((MonetaryUnit)value).value;
21 else
22 return Convert.ToDouble(value);
23 }
24 catch (InvalidCastException e)
25 {
26 throw new InvalidCastException("The " + GetType().NiceTypeName() +
27 " cannot be used for properties of type " + value.GetType().NiceTypeName(), e);
28 }
29 }
30 }
31}
Any attribute that can validate the value of a property.
double GetValue(object value)
Gets the double value corresponding to the supplied object.
Any attribute that can validate the value of a property.
Representation of a monetary value with a currency.