public IngredientsRepository( ILogger <IngredientsRepository> logger, string connectionString = "") : base(logger, connectionString: connectionString) { ExcludedPropertyNames.Add(nameof(Ingredient.Amount)); LoadEntityProperties(); }
private bool IgnoreProperty <T>(PropertyInfo property) { if (ExcludedPropertyNames.Any(p => p.ToLower() == property.Name.ToLower())) { return(true); } if (ExcludedTypeProperties.Any(t => t.Type == typeof(T) && t.PropertyName.ToLower() == property.Name.ToLower())) { return(true); } return(false); }
private void WhenTargetPropertyNotFound(string[] tomlKeyChain, object targetObject, TomlObject targetValue) { var lineNumber = GuessSourceLine(tomlKeyChain, targetValue); var targetType = targetObject .GetType(); var typeName = targetType .FullName ?.Replace($"{nameof(TabularCsv)}.", string.Empty); var propertyName = $"{typeName}.{string.Join(".", tomlKeyChain)}"; var targetPropertyName = tomlKeyChain.LastOrDefault(); var targetSectionName = tomlKeyChain.Length > 1 ? tomlKeyChain[tomlKeyChain.Length - 2] : default; var message = $"'{propertyName}' is not a known property name."; if (!string.IsNullOrEmpty(targetPropertyName) && !string.IsNullOrEmpty(targetSectionName)) { message = $"'{targetPropertyName}' is not a known [{targetSectionName}] property name."; } if (!string.IsNullOrEmpty(targetPropertyName)) { var bestGuess = BestGuess( targetPropertyName, targetType .GetProperties(BindingFlags.Public | BindingFlags.Instance | BindingFlags.SetProperty) .Where(p => !ExcludedPropertyNames.Contains(p.Name)), propertyInfo => propertyInfo.Name); if (!string.IsNullOrEmpty(bestGuess)) { message = $"{message} {bestGuess}"; } } message = $"{message} See https://github.com/AquaticInformatics/tabular-field-data-plugin/wiki/Configuration-Fields for details."; if (lineNumber.HasValue) { throw new ParseException($"Line {lineNumber}: {message}"); } throw new ParseException(message); }