<commit_before>﻿using System;
using System.Collections.Concurrent;
using NPoco;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Composing;

namespace Umbraco.Core.Persistence.Mappers
{
    public abstract class BaseMapper : IDiscoverable
    {
        // note: using a Lazy<ISqlContext> here because during installs, we are resolving the
        // mappers way before we have a configured IUmbracoDatabaseFactory, ie way before we
        // have an ISqlContext - this is some nasty temporal coupling which we might want to
        // cleanup eventually.

        private readonly Lazy<ISqlContext> _sqlContext;
        private readonly object _definedLock = new object();
        private readonly ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> _maps;

        private ISqlSyntaxProvider _sqlSyntax;
        private bool _defined;

        protected BaseMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
        {
            _sqlContext = sqlContext;
            _maps = maps;
        }

        protected abstract void DefineMaps();

        internal string Map(string propertyName)
        {
            lock (_definedLock)<commit_msg>BaseMapper does not need be IDiscoverable<commit_after>﻿using System;
using System.Collections.Concurrent;
using NPoco;
using Umbraco.Core.Persistence.SqlSyntax;
using Umbraco.Core.Composing;

namespace Umbraco.Core.Persistence.Mappers
{
    public abstract class BaseMapper
    {
        // note: using a Lazy<ISqlContext> here because during installs, we are resolving the
        // mappers way before we have a configured IUmbracoDatabaseFactory, ie way before we
        // have an ISqlContext - this is some nasty temporal coupling which we might want to
        // cleanup eventually.

        private readonly Lazy<ISqlContext> _sqlContext;
        private readonly object _definedLock = new object();
        private readonly ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> _maps;

        private ISqlSyntaxProvider _sqlSyntax;
        private bool _defined;

        protected BaseMapper(Lazy<ISqlContext> sqlContext, ConcurrentDictionary<Type, ConcurrentDictionary<string, string>> maps)
        {
            _sqlContext = sqlContext;
            _maps = maps;
        }

        protected abstract void DefineMaps();

        internal string Map(string propertyName)
        {
            lock (_definedLock)
{'fraction_non_alphanumeric': 0.06285482562854826, 'fraction_numerical': 0.0, 'mean_word_length': 3.044262295081967, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5707593', 'n_tokens_mistral': 627, 'n_tokens_neox': 613, 'n_words': 203}