예제 #1
0
        private IDataSheetCell FindMatchingCell <TModel>(PropertyInfo property, IDataSheetRow headerRow,
                                                         IReadOnlyList <MemberSpec <TModel> > specs) where TModel : class
        {
            if (specs.Any())
            {
                var propertySpec =
                    specs.SingleOrDefault(
                        s => _propertyInfoExtractor.GetPropertyInfo(s.DestinationMember).Name == property.Name);
                if (propertySpec.AnyValue())
                {
                    if (propertySpec.Is <IgnoreColumn>())
                    {
                        LogIgnoringProperty(property);
                        return(null);
                    }

                    return(propertySpec.SelectCellOrThrow(headerRow));
                }
            }

            var selector = Resolve.ByConvention(property.Name, _conventionsApplier,
                                                StringComparison.InvariantCultureIgnoreCase);
            var cell = selector.SelectCell(headerRow);

            if (cell == null)
            {
                throw new UnmapppedPropertyException(property.Name, headerRow);
            }

            return(cell);
        }