Beispiel #1
0
        private static TypeAdapterConfig UseAutoMappedTypesAndRegister(Assembly assembly)
        {
            Type[] types = assembly.GetTypes().Where(type =>
                                                     type.GetTypeInfo().IsDefined(typeof(AutoMapAttribute))
                                                     ).ToArray();

            var configurations = new TypeAdapterConfig();

            foreach (Type type in types)
            {
                configurations.CreateAutoAttributeMaps(type);
            }
            return(configurations);
        }
        private void FindAndAutoMapTypes(TypeAdapterConfig configuration)
        {
            Type[] types = _typeFinder.Find(type =>
                                            type.GetTypeInfo().IsDefined(typeof(AutoMapAttribute)) ||
                                            type.GetTypeInfo().IsDefined(typeof(AutoMapFromAttribute)) ||
                                            type.GetTypeInfo().IsDefined(typeof(AutoMapToAttribute))
                                            );

            Logger.Debug($"Found {types.Length} classes define auto mapping attributes");

            foreach (Type type in types)
            {
                Logger.Debug(type.FullName);
                configuration.CreateAutoAttributeMaps(type);
            }
        }