using System; using System.Collections.Generic; using System.Linq; using System.Text; namespace NominaWF.Utils.BasicMethods { static class Basic { internal static Func ToDouble = (Obj) => { if (null != Obj) { double valueCost = 0; double.TryParse(Obj.ToString(), out valueCost); return valueCost; } return 0; }; internal static Func ToInt = (Obj) => { if (null != Obj) { int valueCost = 0; int.TryParse(Obj.ToString(), out valueCost); return valueCost; } return 0; }; internal static Func ToStringSecure = (Obj) => { if(Obj != null) { return Obj.ToString(); } return string.Empty; }; internal static Func ToBool = (Obj) => { if (Obj != null) { bool valueBool = false; bool.TryParse(Obj.ToString(), out valueBool); return valueBool; } return false; }; internal static Func ToDate= (Obj) => { DateTime date = DateTime.MinValue; if (Obj != null) { DateTime.TryParse(Obj.ToString(), out date); return date; } return date; }; } }