private void AddAssembliesCore(RelatedDtoLoaderAssemblyOptions options, IEnumerable <Assembly> assembliesToScan)
        {
            options = options ?? new RelatedDtoLoaderAssemblyOptions();

            var allTypes = assembliesToScan.Where(a => !a.IsDynamic && a != typeof(NamedProfile).Assembly)
                           .SelectMany(a => a.DefinedTypes)
                           .Where(x => !x.IsAbstract)
                           .ToArray();

            var profileTypes = allTypes.Where(x => ProfileType.IsAssignableFrom(x)).ToArray();

            foreach (var type in profileTypes)
            {
                var profile = (IRelatedDtoLoaderProfile)Activator.CreateInstance(type);
                AddProfile(profile);
            }

            var dynamicLoaderProfile = new NamedProfile();

            if (options.AutoEnableTargetDtoTypes)
            {
                var dtoTypes = allTypes.Where(x => EntityDtoType.IsAssignableFrom(x)).ToArray();

                foreach (var type in dtoTypes)
                {
                    if (EntityDtoType.IsAssignableFrom(type))
                    {
                        dynamicLoaderProfile.LoadForDto(type);
                    }
                }
            }

            AddProfile(dynamicLoaderProfile);
        }
 public void AddAssemblies(RelatedDtoLoaderAssemblyOptions options, params Assembly[] assembliesToScan)
 {
     AddAssembliesCore(options, assembliesToScan);
 }