public static string OdooTableName(this IOdooAtributtesModel model) { if (!(model.GetType().GetCustomAttributes(typeof(OdooTableNameAttribute), true).FirstOrDefault() is OdooTableNameAttribute attribute)) { throw new ArgumentException($"Mising attribute '{nameof(OdooTableNameAttribute)}' for model '{model.GetType().Name}'"); } return(attribute.Name); }
public static string OdooPropertyName(this IOdooAtributtesModel model, string name) { var key = model.GetType().GetProperties().First(x => x.Name == name).GetCustomAttributes <JsonPropertyAttribute>().FirstOrDefault(); if (key == null) { throw new ArgumentException($"Mising attribute '{nameof(JsonPropertyAttribute)}' for property '{name}' in model '{model.GetType().Name}'"); } return(key.PropertyName); }