示例#1
0
        private object GetValor(MyPropertyInfo propriedade, object valor)
        {
            switch (propriedade.Property.PropertyType.FullName)
            {
            case "System.String":
                return(valor.ToString());

            case "System.Decimal":
                return(Convert.ToDecimal(valor.ToString()));

            case "System.Guid":
                return(new Guid(valor.ToString()));
            }
            return(null);
        }
示例#2
0
 private void MontarLista()
 {
     Propriedades           = new Dictionary <string, MyPropertyInfo>();
     PropriedadesComDefault = new Dictionary <string, MyPropertyInfo>();
     foreach (PropertyInfo property in typeof(T).GetProperties())
     {
         var dd = property.GetCustomAttribute(typeof(DisplayAttribute)) as DisplayAttribute;
         if (dd != null)
         {
             var value = property.GetCustomAttribute(typeof(DefaultValue)) as DefaultValue;
             var prop  = new MyPropertyInfo()
             {
                 Property     = property,
                 DefaultValue = value != null ? value.Value : null
             };
             Propriedades.Add(dd.Name.ToUpper(), prop);
             if (prop.DefaultValue != null)
             {
                 PropriedadesComDefault.Add(dd.Name.ToUpper(), prop);
             }
         }
     }
 }