Ejemplo n.º 1
0
 private static void SetDefaultValues <T>(PropertyValueAttribute attribute, PropertyInfo property, T inst) where T : new()
 {
     if (attribute.Value != null && property.PropertyType == attribute.Value.GetType())
     {
         property.SetValue(inst, attribute.Value, null); // null means no indexes
     }
     else if (property.PropertyType == typeof(string))
     {
         property.SetValue(inst, attribute.Name, null);
     }
 }
Ejemplo n.º 2
0
 /// <summary>
 /// Gets the <see cref="PropertyValueAttribute"/> if present.
 /// </summary>
 /// <returns>The instance of <see cref="PropertyValueAttribute"/>.</returns>
 public PropertyValueAttribute GetDbTypeAttribute()
 {
     if (isDbTypeAttributeWasSet)
     {
         return(propertyValueAttribute);
     }
     isDbTypeAttributeWasSet = true;
     return(propertyValueAttribute = (PropertyInfo.GetCustomAttribute(StaticType.DbTypeAttribute) ??
                                      PropertyInfo.GetCustomAttribute(StaticType.TypeMapAttribute)) as DbTypeAttribute ??
                                     (GetPropertyValueAttributes()
                                      .Where(
                                          e => string.Equals(nameof(IDbDataParameter.ParameterName), e.PropertyName, StringComparison.OrdinalIgnoreCase))
                                      .LastOrDefault()));
 }