コード例 #1
0
 private ObjectMapper CreateObjectMapper(TableMap tableMap, IEnumerable<DataColumnInfo> schema)
 {
     var instanceFactory = _configuration.InstanceFactoryProviders.FirstOrDefault(x => x.CanHandle(tableMap.Type)) ??
                                  new DefaultInstanceFactory();
     var mapper = new ObjectMapper(instanceFactory);
     mapper.Initialize(tableMap, schema);
     return mapper;
 }
コード例 #2
0
        public IEnumerable<IDataParameter> Map(object input, TableMap tableMap)
        {
            if (input == null)
                return Enumerable.Empty<IDataParameter>();

            var dataParameters = input as IEnumerable<IDataParameter>;
            if (dataParameters != null)
                return dataParameters;

            throw new NotImplementedException();
        }
コード例 #3
0
 public void Initialize(TableMap tableMap, IEnumerable<DataColumnInfo> schema)
 {
     var dictionary = schema.ToDictionary(x => x.Name.ToLower(), x => x.Index);
     foreach (var propertyMap in tableMap.Columns)
     {
         int index;
         if (!dictionary.TryGetValue(propertyMap.ColumnName.ToLower(), out index)) continue;
         var setter = PropertySetter.Create(tableMap.Type, propertyMap.PropertyName);
         _recordToPropertyMappers.Add(new DataRecordToPropertyMapper(index, setter, propertyMap.Serializer));
     }
 }
コード例 #4
0
        private IInstanceMapper CreateMapper(TableMap tableMap, IEnumerable<DataColumnInfo> schema)
        {
            var targetType = tableMap.Type;
            if (targetType == typeof(ExpandoObject))
                return new ExpandoObjectMapper();

            if (targetType.IsGenericType && targetType.GetGenericTypeDefinition() == typeof(DataEntityTuple<>))
                return CreateDataEntityTupleMapper(tableMap, schema);

            return CreateObjectMapper(tableMap, schema);
        }
コード例 #5
0
 public ParameterBuilderFactory(TableMap tableMap)
 {
     _tableMap = tableMap;
 }
コード例 #6
0
 private IInstanceMapper CreateDataEntityTupleMapper(TableMap tableMap, IEnumerable<DataColumnInfo> schema)
 {
     var expandoObjectMapper = new ExpandoObjectMapper();
     var objectMapper = CreateObjectMapper(tableMap, schema);
     return new DataEntityTupleMapper(expandoObjectMapper, objectMapper);
 }
コード例 #7
0
 public void Add(Type type, TableMap tableMap)
 {
     _dictionary.Add(type, tableMap);
 }