Exemplo n.º 1
0
        public NamingSettings(CacheSet mapperScopedCache)
        {
            _idMemberCache = mapperScopedCache.CreateScopedWithHashCodes <TypeKey, Member>();

            _matchingNameFactories = new List <ConfiguredNamingPattern>
            {
                ConfiguredNamingPattern.Global(member => IsTypeIdentifier(member) ? "Id" : null),
                ConfiguredNamingPattern.ForGetOrSetMethod,
                ConfiguredNamingPattern.ForIdentifierName
            };

            _joinedNameFactories = new List <Func <IEnumerable <string>, string> >
            {
                names => names.Join(string.Empty),
                names => names.Join(".")
            };
        }
 private MappingConfigurator <TSource, TTarget> UseNamePatterns(params string[] patterns)
 {
     MapperContext.Naming.Add(ConfiguredNamingPattern.Create(patterns, ConfigInfo));
     return(this);
 }
 private MappingConfigurator <TSource, TTarget> UseNameSuffixes(params string[] suffixes)
 {
     MapperContext.Naming.Add(ConfiguredNamingPattern.Suffixes(suffixes, ConfigInfo));
     return(this);
 }
Exemplo n.º 4
0
 /// <summary>
 /// Expect members of all source and target types to potentially match the given name <paramref name="patterns"/>.
 /// The patterns will be used to find the part of a name which should be used to match a source and target member.
 /// </summary>
 /// <param name="patterns">
 /// The Regex patterns to check against source and target member names. Each pattern is expected to start with the
 /// ^ character, end with the $ character and contain a single capturing group wrapped in parentheses, e.g. ^__(.+)__$
 /// </param>
 /// <returns>
 /// An <see cref="IGlobalMappingSettings"/>, with which to globally configure other mapping aspects.
 /// </returns>
 public IGlobalMappingSettings UseNamePatterns(params string[] patterns)
 {
     MapperContext.Naming.Add(ConfiguredNamingPattern.Create(patterns, GlobalConfigInfo));
     return(this);
 }
Exemplo n.º 5
0
 /// <summary>
 /// Expect members of all source and target types to potentially have any of the given name <paramref name="suffixes"/>.
 /// Source and target members will be matched as if the suffixes are absent.
 /// </summary>
 /// <param name="suffixes">The suffixes to ignore when matching source and target members.</param>
 /// <returns>
 /// An <see cref="IGlobalMappingSettings"/>, with which to globally configure other mapping aspects.
 /// </returns>
 public IGlobalMappingSettings UseNameSuffixes(params string[] suffixes)
 {
     MapperContext.Naming.Add(ConfiguredNamingPattern.Suffixes(suffixes, GlobalConfigInfo));
     return(this);
 }