Esempio n. 1
0
        private void CreateMappings()
        {
            lock (_syncObj)
            {
                //We should prevent duplicate mapping in an application, since AutoMapper is static.
                if (_createdMappingsBefore)
                {
                    return;
                }

                AutoMapperHelper.Initialize(configuration =>
                {
                    FindAndAutoMapTypes(configuration);
                    CreateOtherMappings(configuration);
                });

                _createdMappingsBefore = true;
            }
        }
Esempio n. 2
0
        private void CreateMappings()
        {
            //We should prevent duplicate mapping in an application, since AutoMapper is static.
            if (_createdMappingsBefore)
            {
                return;
            }

            _createdMappingsBefore = true;

            var types = _typeFinder.Find(type =>
                                         type.IsDefined(typeof(AutoMapAttribute)) ||
                                         type.IsDefined(typeof(AutoMapFromAttribute)) ||
                                         type.IsDefined(typeof(AutoMapToAttribute))
                                         );

            Logger.DebugFormat("Found {0} classes defines auto mapping attributes", types.Length);
            foreach (var type in types)
            {
                Logger.Debug(type.FullName);
                AutoMapperHelper.CreateMap(type);
            }
        }