Ejemplo n.º 1
0
        public SimpleAutoMapperCache()
        {
            _unSealedAutoMappers =
                new LockingConcurrentDictionary <IAutoMapperRequestKeyGen, IAutoMapperRequestKeyGen>(RequestFactory);

            _sealedAutoMappers =
                new LockingConcurrentDictionary <IAutoMapperRequestKeyGen, IMapper>(MapperFactory);
        }
Ejemplo n.º 2
0
 public ConfiguredMappers(Func <Action <IMapperConfigurationExpression>, IConfigurationProvider> baseConfigBuilder,
                          IInitializeAMapperConf mapperConfigInitializerProvider)
 {
     _baseConfigBuilder = baseConfigBuilder;
     _mapperConfigInitializerProvider = mapperConfigInitializerProvider;
     _unSealedPropBagMappers          = new LockingConcurrentDictionary <IPropBagMapperKeyGen, IPropBagMapperKeyGen>(GetPropBagMapperPromise);
     _sealedPropBagMappers            = new LockingConcurrentDictionary <IPropBagMapperKeyGen, IPropBagMapperGen>(GetPropBagMapperReal);
 }
Ejemplo n.º 3
0
        public SimplePropBagMapperCache(ViewModelFactoryInterface viewModelFactory)
        {
            _viewModelFactory = viewModelFactory ?? throw new ArgumentNullException(nameof(viewModelFactory));

            _requests =
                new LockingConcurrentDictionary <IPropBagMapperRequestKeyGen, IPropBagMapperRequestKeyGen>(RequestFactory);

            _propBagMappers =
                new LockingConcurrentDictionary <IPropBagMapperRequestKeyGen, IPropBagMapperGen>(MapperFactory);
        }
Ejemplo n.º 4
0
        public DelegateCache(MethodInfo theMethod)
        {
            _cache     = new LockingConcurrentDictionary <TypeKey, T>(MakeTheDelegate);
            _theMethod = theMethod;

            _typeArguments    = _theMethod.GetGenericArguments();
            _typeArguments[0] = typeof(T);
            for (int ptr = 1; ptr < _typeArguments.Length; ptr++)
            {
                _typeArguments[ptr] = typeof(object);
            }
        }
Ejemplo n.º 5
0
        public ProfileMap(IProfileConfiguration profile, IConfiguration configuration)
        {
            _typeDetails = new LockingConcurrentDictionary<Type, TypeDetails>(TypeDetailsFactory);

            Name = profile.ProfileName;
            AllowNullCollections = profile.AllowNullCollections ?? configuration?.AllowNullCollections ?? false;
            AllowNullDestinationValues = profile.AllowNullDestinationValues ?? configuration?.AllowNullDestinationValues ?? true;
            EnableNullPropagationForQueryMapping = profile.EnableNullPropagationForQueryMapping ?? configuration?.EnableNullPropagationForQueryMapping ?? false;
            ConstructorMappingEnabled = profile.ConstructorMappingEnabled ?? configuration?.ConstructorMappingEnabled ?? true;
            ShouldMapField = profile.ShouldMapField ?? configuration?.ShouldMapField ?? (p => p.IsPublic());
            ShouldMapProperty = profile.ShouldMapProperty ?? configuration?.ShouldMapProperty ?? (p => p.IsPublic());
            CreateMissingTypeMaps = profile.CreateMissingTypeMaps ?? configuration?.CreateMissingTypeMaps ?? false;

            TypeConfigurations = profile.TypeConfigurations
                .Concat(configuration?.TypeConfigurations ?? Enumerable.Empty<IConditionalObjectMapper>())
                .Concat(CreateMissingTypeMaps
                    ? Enumerable.Repeat(new ConditionalObjectMapper { Conventions = { tp => tp.SourceType != typeof(object) && tp.DestinationType != typeof(object) } }, 1)
                    : Enumerable.Empty<IConditionalObjectMapper>())
                .ToArray();


            MemberConfigurations = profile.MemberConfigurations.ToArray();

            MemberConfigurations.FirstOrDefault()?.AddMember<NameSplitMember>(_ => _.SourceMemberNamingConvention = profile.SourceMemberNamingConvention);
            MemberConfigurations.FirstOrDefault()?.AddMember<NameSplitMember>(_ => _.DestinationMemberNamingConvention = profile.DestinationMemberNamingConvention);

            GlobalIgnores = profile.GlobalIgnores.Concat(configuration?.GlobalIgnores ?? Enumerable.Empty<string>()).ToArray();
            SourceExtensionMethods = profile.SourceExtensionMethods.Concat(configuration?.SourceExtensionMethods ?? Enumerable.Empty<MethodInfo>()).ToArray();
            AllPropertyMapActions = profile.AllPropertyMapActions.Concat(configuration?.AllPropertyMapActions ?? Enumerable.Empty<Action<PropertyMap, IMemberConfigurationExpression>>()).ToArray();
            AllTypeMapActions = profile.AllTypeMapActions.Concat(configuration?.AllTypeMapActions ?? Enumerable.Empty<Action<TypeMap, IMappingExpression>>()).ToArray();

            Prefixes =
                profile.MemberConfigurations
                    .Select(m => m.NameMapper)
                    .SelectMany(m => m.NamedMappers)
                    .OfType<PrePostfixName>()
                    .SelectMany(m => m.Prefixes)
                    .ToArray();

            Postfixes =
                profile.MemberConfigurations
                    .Select(m => m.NameMapper)
                    .SelectMany(m => m.NamedMappers)
                    .OfType<PrePostfixName>()
                    .SelectMany(m => m.Postfixes)
                    .ToArray();

            _typeMapConfigs = profile.TypeMapConfigs.ToArray();
            _openTypeMapConfigs = profile.OpenTypeMapConfigs.ToArray();
        }
Ejemplo n.º 6
0
 public ExpressionBuilder(IConfigurationProvider configurationProvider)
 {
     _configurationProvider = configurationProvider;
     _expressionCache       = new LockingConcurrentDictionary <ExpressionRequest, LambdaExpression[]>(CreateMapExpression);
 }
Ejemplo n.º 7
0
 public SimpleEmittedTypesCache(IEmitWrapperType emitterEngine)
 {
     _emittedTypes = new LockingConcurrentDictionary <TypeDescription, Type>(emitterEngine.EmitWrapperType);
 }
Ejemplo n.º 8
0
 public TwoTypesDelegateCache(MethodInfo theMethod)
 {
     _cache     = new LockingConcurrentDictionary <TypePair, T>(MakeTheDelegate);
     _theMethod = theMethod;
 }
Ejemplo n.º 9
0
 public TypeDescriptionLocalCache(ITypeDescriptionProvider typeDescriptionProvider)
 {
     _typeDescriptions = new LockingConcurrentDictionary <NewTypeRequest, TypeDescription>
                             (typeDescriptionProvider.GetTypeDescription);
 }
Ejemplo n.º 10
0
 public ProfileMap(IProfileConfiguration profile, IConfiguration configuration)
 {
     _typeDetails    = new LockingConcurrentDictionary <Type, TypeDetails>(t => new TypeDetails(t, this));
     _typeMapConfigs = profile.TypeMapConfigs.ToArray();
 }