internal ConventionContext(ObjectMapper container, Type sourceType, Type targetType, MemberMapOptions options) { _container = container; _sourceType = sourceType; _targetType = targetType; _options = options; _sourceMembers = new MappingMemberCollection(GetMembers(sourceType, true, false)); _targetMembers = new MappingMemberCollection(GetMembers(targetType, false, true)); }
private void Initialize() { if (!_initialized) { Thread.MemoryBarrier(); lock (_lockObj) { if (!_initialized) { var context = new ConventionContext(_container, typeof(TSource), typeof(TTarget), _options); _container.Conventions.Apply(context); _targetMembers = context.TargetMembers; _memberMappers = new MemberMapperCollection(_container, _options); foreach (MemberMapping mapping in context.Mappings) { _memberMappers.Set(mapping.TargetMember, mapping.SourceMember, mapping.Converter); } _initialized = true; } } } }