Skip to content

Commit 5c44954

Browse files
Tyler CarlsonTyler Carlson
authored andcommitted
Update Configurations to Use IConfigurationProvider directly
1 parent 10272b8 commit 5c44954

16 files changed

Lines changed: 39 additions & 53 deletions

src/AutoMapper.Collection/AutoMapper.Collection.EntityFramework/AutoMapper.Collection.EntityFramework.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,8 @@
3636
</PropertyGroup>
3737
<ItemGroup>
3838
<Reference Include="AutoMapper, Version=5.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
39-
<HintPath>..\packages\AutoMapper.5.0.0-ci-1068\lib\net45\AutoMapper.dll</HintPath>
39+
<HintPath>..\packages\AutoMapper.5.0.0-beta-1\lib\net45\AutoMapper.dll</HintPath>
40+
<SpecificVersion>False</SpecificVersion>
4041
<Private>True</Private>
4142
</Reference>
4243
<Reference Include="EntityFramework, Version=6.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089, processorArchitecture=MSIL">

src/AutoMapper.Collection/AutoMapper.Collection.EntityFramework/Extensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ public static class Extensions
1515
/// <typeparam name="TSource">Source table type to be updated</typeparam>
1616
/// <param name="source">DbSet to be updated</param>
1717
/// <returns>Persistance object to Update or Remove data</returns>
18-
[Obsolete("Use version that passes instance of IMapper")]
1918
public static IPersistance Persist<TSource>(this DbSet<TSource> source)
2019
where TSource : class
2120
{
22-
return new Persistance<TSource>(source, null);
21+
return new Persistance<TSource>(source, Mapper.Instance);
2322
}
2423

2524
/// <summary>

src/AutoMapper.Collection/AutoMapper.Collection.EntityFramework/GenerateEntityFrameworkPrimaryKeyEquivilentExpressions.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,8 @@ public class GenerateEntityFrameworkPrimaryKeyEquivilentExpressions<TDatabaseCon
1515
/// Generate EquivilencyExpressions based on EnityFramework's primary key
1616
/// </summary>
1717
/// <param name="mapper">IMapper used to find TypeMap between classes</param>
18-
public GenerateEntityFrameworkPrimaryKeyEquivilentExpressions(IMapper mapper)
19-
: base(new GenerateEntityFrameworkPrimaryKeyPropertyMaps<TDatabaseContext>(mapper))
20-
{
21-
}
22-
23-
/// <summary>
24-
/// Generate EquivilencyExpressions based on EnityFramework's primary key
25-
/// Uses static API's Mapper for finding TypeMap between classes
26-
/// </summary>
27-
[Obsolete("Use version that passes instance of IMapper")]
28-
public GenerateEntityFrameworkPrimaryKeyEquivilentExpressions()
29-
: base(new GenerateEntityFrameworkPrimaryKeyPropertyMaps<TDatabaseContext>(null))
18+
public GenerateEntityFrameworkPrimaryKeyEquivilentExpressions(IConfigurationProvider configurationProvider)
19+
: base(new GenerateEntityFrameworkPrimaryKeyPropertyMaps<TDatabaseContext>(configurationProvider))
3020
{
3121
}
3222
}

src/AutoMapper.Collection/AutoMapper.Collection.EntityFramework/GenerateEntityFrameworkPrimaryKeyPropertyMatches.cs

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,21 +12,19 @@ namespace AutoMapper.EntityFramework
1212
public class GenerateEntityFrameworkPrimaryKeyPropertyMaps<TDatabaseContext> : IGeneratePropertyMaps
1313
where TDatabaseContext : IObjectContextAdapter, new()
1414
{
15-
private readonly IMapper _mapper;
15+
private readonly IConfigurationProvider _configurationProvider;
1616

1717
private readonly TDatabaseContext _context = new TDatabaseContext();
1818
private readonly MethodInfo _createObjectSetMethodInfo = typeof(ObjectContext).GetMethod("CreateObjectSet", Type.EmptyTypes);
1919

20-
public GenerateEntityFrameworkPrimaryKeyPropertyMaps(IMapper mapper)
20+
public GenerateEntityFrameworkPrimaryKeyPropertyMaps(IConfigurationProvider configurationProvider)
2121
{
22-
_mapper = mapper;
22+
_configurationProvider = configurationProvider;
2323
}
2424

2525
public IEnumerable<PropertyMap> GeneratePropertyMaps(Type srcType, Type destType)
2626
{
27-
var typeMap = _mapper == null
28-
? (Mapper.Configuration as IConfigurationProvider).ResolveTypeMap(srcType, destType)
29-
: _mapper.ConfigurationProvider.ResolveTypeMap(srcType, destType);
27+
var typeMap = _configurationProvider.ResolveTypeMap(srcType, destType);
3028
var propertyMaps = typeMap.GetPropertyMaps();
3129
var createObjectSetMethod = _createObjectSetMethodInfo.MakeGenericMethod(destType);
3230
dynamic objectSet = createObjectSetMethod.Invoke(_context.ObjectContext, null);

src/AutoMapper.Collection/AutoMapper.Collection.EntityFramework/Properties/AssemblyInfo.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,5 @@
3232
// You can specify all the values or you can default the Build and Revision Numbers
3333
// by using the '*' as shown below:
3434
// [assembly: AssemblyVersion("1.0.*")]
35-
[assembly: AssemblyVersion("1.2.0.0")]
36-
[assembly: AssemblyFileVersion("1.2.0.0")]
35+
[assembly: AssemblyVersion("2.0.0.0")]
36+
[assembly: AssemblyFileVersion("2.0.0.0")]
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<packages>
3-
<package id="AutoMapper" version="5.0.0-ci-1068" targetFramework="net45" />
3+
<package id="AutoMapper" version="5.0.0-beta-1" targetFramework="net45" />
44
<package id="EntityFramework" version="6.1.3" targetFramework="net451" />
55
<package id="Microsoft.Bcl.Build" version="1.0.14" targetFramework="net45" />
66
</packages>

src/AutoMapper.Collection/AutoMapper.Collection.LinqToSQL/AutoMapper.Collection.LinqToSQL.csproj

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,8 @@
3434
</PropertyGroup>
3535
<ItemGroup>
3636
<Reference Include="AutoMapper, Version=5.0.0.0, Culture=neutral, PublicKeyToken=be96cd2c38ef1005, processorArchitecture=MSIL">
37-
<HintPath>..\packages\AutoMapper.5.0.0-ci-1068\lib\net45\AutoMapper.dll</HintPath>
37+
<HintPath>..\packages\AutoMapper.5.0.0-beta-1\lib\net45\AutoMapper.dll</HintPath>
38+
<SpecificVersion>False</SpecificVersion>
3839
<Private>True</Private>
3940
</Reference>
4041
<Reference Include="Microsoft.CSharp" />

src/AutoMapper.Collection/AutoMapper.Collection.LinqToSQL/GetLinqToSQLPrimaryKeyExpression.cs

Lines changed: 2 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,8 @@ public class GetLinqToSQLPrimaryKeyExpression : GenerateEquivilentExpressionsBas
99
/// Generate EquivilencyExpressions based on LinqToSQL's primary key
1010
/// </summary>
1111
/// <param name="mapper">IMapper used to find TypeMap between classes</param>
12-
public GetLinqToSQLPrimaryKeyExpression(IMapper mapper)
13-
: base(new GetLinqToSQLPrimaryKeyProperties(mapper))
14-
{
15-
}
16-
17-
/// <summary>
18-
/// Generate EquivilencyExpressions based on LinqToSQL's primary key
19-
/// Uses static API's Mapper for finding TypeMap between classes
20-
[Obsolete("Use version that passes instance of IMapper")]
21-
/// </summary>
22-
public GetLinqToSQLPrimaryKeyExpression()
23-
: base(new GetLinqToSQLPrimaryKeyProperties(null))
12+
public GetLinqToSQLPrimaryKeyExpression(IConfigurationProvider configurationProvider)
13+
: base(new GetLinqToSQLPrimaryKeyProperties(configurationProvider))
2414
{
2515
}
2616
}

src/AutoMapper.Collection/AutoMapper.Collection.LinqToSQL/GetLinqToSQLPrimaryKeyProperties.cs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -9,18 +9,18 @@ namespace AutoMapper.Collection.LinqToSQL
99
{
1010
public class GetLinqToSQLPrimaryKeyProperties : IGeneratePropertyMaps
1111
{
12-
private readonly IMapper _mapper;
13-
14-
public GetLinqToSQLPrimaryKeyProperties(IMapper mapper)
12+
private readonly IConfigurationProvider _configurationProvider;
13+
14+
public GetLinqToSQLPrimaryKeyProperties(IConfigurationProvider configurationProvider)
1515
{
16-
_mapper = mapper;
16+
if (configurationProvider == null)
17+
throw new ArgumentNullException(nameof(configurationProvider));
18+
_configurationProvider = configurationProvider;
1719
}
1820

1921
public IEnumerable<PropertyMap> GeneratePropertyMaps(Type srcType, Type destType)
2022
{
21-
var typeMap = _mapper == null
22-
? (Mapper.Configuration as IConfigurationProvider).ResolveTypeMap(srcType, destType)
23-
: _mapper.ConfigurationProvider.ResolveTypeMap(srcType, destType);
23+
var typeMap = _configurationProvider.ResolveTypeMap(srcType, destType);
2424
var propertyMaps = typeMap.GetPropertyMaps();
2525

2626
var primaryKeyPropertyMatches = destType.GetProperties().Where(IsPrimaryKey).Select(m => propertyMaps.FirstOrDefault(p => p.DestinationProperty.Name == m.Name)).ToList();

src/AutoMapper.Collection/AutoMapper.Collection.LinqToSQL/PersistanceExtensions.cs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,11 +15,10 @@ public static class PersistanceExtensions
1515
/// <typeparam name="TSource">Source table type to be updated</typeparam>
1616
/// <param name="source">Table to be updated</param>
1717
/// <returns>Persistance object to Update or Remove data</returns>
18-
[Obsolete("Use version that passes instance of IMapper")]
1918
public static IPersistance Persist<TSource>(this Table<TSource> source)
2019
where TSource : class
2120
{
22-
return new Persistance<TSource>(source, null);
21+
return new Persistance<TSource>(source, Mapper.Instance);
2322
}
2423

2524
/// <summary>

0 commit comments

Comments
 (0)