Exemplo n.º 1
0
        public IEnumerable <T> MapTo <T>(Document tabularData, MappingDefinition map)
        {
            var convertedData = new List <T>();

            foreach (var row in tabularData.Rows)
            {
                var type = typeof(T);
                var data = Activator.CreateInstance <T>();
                foreach (var fieldMap in map.Fields)
                {
                    var memberInfo = type.GetMember(fieldMap.TargetMemberName, fieldMap.MemberType, BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public).First();
                    type.InvokeMember(fieldMap.TargetMemberName, GetBindingFlags(fieldMap), Type.DefaultBinder, data, new[] { GetValueFromRow <T>(tabularData, row, fieldMap, memberInfo) });
                }
                convertedData.Add(data);
            }
            return(convertedData);
        }
Exemplo n.º 2
0
 public static IEnumerable <T> ConvertTo <T>(this Document doc, MappingDefinition map)
 {
     return(Resolver.Activate <ITabularMapper>().MapTo <T>(doc, map));
 }