Permalink
Browse files

Merge pull request #1883 from TylerCarlson1/AdvancedBeforeSeal

Add Advanced property and put BeforeSeal function in it
  • Loading branch information...
2 parents c04f98f + 3196529 commit 0f29418497958dd3eeff9a5145fd446fb0e3baf8 @jbogard jbogard committed on GitHub Jan 11, 2017
@@ -0,0 +1,19 @@
+using System;
+using System.Collections.Generic;
+
+namespace AutoMapper
+{
+ public class AdvancedConfiguration
+ {
+ private readonly IList<Action<IConfigurationProvider>> _beforeSealActions = new List<Action<IConfigurationProvider>>();
+ public IEnumerable<Action<IConfigurationProvider>> BeforeSealActions => _beforeSealActions;
+
+ /// <summary>
+ /// Add Action called against the IConfigurationProvider before it gets sealed
+ /// </summary>
+ public void BeforeSeal(Action<IConfigurationProvider> action)
+ {
+ _beforeSealActions.Add(action);
+ }
+ }
+}
@@ -25,6 +25,8 @@ public void CreateProfile(string profileName, Action<IProfileExpression> config)
public IList<IObjectMapper> Mappers { get; }
+ public AdvancedConfiguration Advanced { get; } = new AdvancedConfiguration();
+
private class NamedProfile : Profile
{
public NamedProfile(string profileName, Action<IProfileExpression> config) : base(profileName, config)
@@ -82,5 +82,10 @@ public interface IMapperConfigurationExpression : IProfileExpression
/// Object mappers
/// </summary>
IList<IObjectMapper> Mappers { get; }
+
+ /// <summary>
+ /// Advance Configuration
+ /// </summary>
+ AdvancedConfiguration Advanced { get; }
}
}
@@ -37,6 +37,8 @@ public MapperConfiguration(MapperConfigurationExpression configurationExpression
Configuration = new ProfileMap(configurationExpression);
Profiles = new[] { Configuration }.Concat(configurationExpression.Profiles.Select(p => new ProfileMap(p, configurationExpression))).ToArray();
+ foreach (var beforeSealAction in configurationExpression.Advanced.BeforeSealActions)
+ beforeSealAction?.Invoke(this);
Seal();
}
Oops, something went wrong.

0 comments on commit 0f29418

Please sign in to comment.