<commit_before>﻿// <copyright file="EntityConfigurationWrapper.cs" company="dddlib contributors">
//  Copyright (c) dddlib contributors. All rights reserved.
// </copyright>

namespace dddlib.Sdk.Configuration.Model.BootstrapperService
{
    using System;
    using System.Collections.Generic;
    using System.Linq.Expressions;
    using dddlib.Configuration;
    using dddlib.Sdk.Configuration.Model;

    internal class EntityConfigurationWrapper<T> : IEntityConfigurationWrapper<T>
        where T : Entity
    {
        private readonly EntityType entityType;
        private readonly ITypeAnalyzerService typeAnalyzerService;

        public EntityConfigurationWrapper(EntityType entityType, ITypeAnalyzerService typeAnalyzerService)
        {
            Guard.Against.Null(() => entityType);
            Guard.Against.Null(() => typeAnalyzerService);

            this.entityType = entityType;
            this.typeAnalyzerService = typeAnalyzerService;
        }

        public IEntityConfigurationWrapper<T> ToUseNaturalKey<TKey>(Expression<Func<T, TKey>> naturalKeySelector)
        {
            Guard.Against.InvalidMemberExpression(() => naturalKeySelector, out var memberExpression);

            var naturalKey = new NaturalKey(typeof(T), memberExpression.Member.Name, typeof(TKey), this.typeAnalyzerService);
            this.entityType.ConfigureNaturalKey(naturalKey);

            return this;
        }

        public IEntityConfigurationWrapper<T> ToUseNaturalKey(
            Expression<Func<T, string>> naturalKeySelector, IEqualityComparer<string> equalityComparer)
        {
            Guard.Against.InvalidMemberExpression(() => naturalKeySelector, out var memberExpression);

            var naturalKey = new NaturalKey(typeof(T), memberExpression.Member.Name, typeof(string), this.typeAnalyzerService);
            this.entityType.ConfigureNaturalKey(naturalKey, equalityComparer);<commit_msg>Fixed #4 by changing entity configuration wrapper<commit_after>﻿// <copyright file="EntityConfigurationWrapper.cs" company="dddlib contributors">
//  Copyright (c) dddlib contributors. All rights reserved.
// </copyright>

namespace dddlib.Sdk.Configuration.Model.BootstrapperService
{
    using System;
    using System.Collections.Generic;
    using System.Linq.Expressions;
    using dddlib.Configuration;
    using dddlib.Sdk.Configuration.Model;

    internal class EntityConfigurationWrapper<T> : IEntityConfigurationWrapper<T>
        where T : Entity
    {
        private readonly EntityType entityType;
        private readonly ITypeAnalyzerService typeAnalyzerService;

        public EntityConfigurationWrapper(EntityType entityType, ITypeAnalyzerService typeAnalyzerService)
        {
            Guard.Against.Null(() => entityType);
            Guard.Against.Null(() => typeAnalyzerService);

            this.entityType = entityType;
            this.typeAnalyzerService = typeAnalyzerService;
        }

        public IEntityConfigurationWrapper<T> ToUseNaturalKey<TKey>(Expression<Func<T, TKey>> naturalKeySelector)
        {
            var memberExpression = default(MemberExpression);
            Guard.Against.InvalidMemberExpression(() => naturalKeySelector, out memberExpression);

            var naturalKey = new NaturalKey(typeof(T), memberExpression.Member.Name, typeof(TKey), this.typeAnalyzerService);
            this.entityType.ConfigureNaturalKey(naturalKey);

            return this;
        }

        public IEntityConfigurationWrapper<T> ToUseNaturalKey(
            Expression<Func<T, string>> naturalKeySelector, IEqualityComparer<string> equalityComparer)
        {
            var memberExpression = default(MemberExpression);
            Guard.Against.InvalidMemberExpression(() => naturalKeySelector, out memberExpression);

            var naturalKey = new NaturalKey(typeof(T), memberExpression.Member.Name, typeof(string), this.typeAnalyzerService);
            this.entityType.ConfigureNaturalKey(naturalKey, equalityComparer);
{'fraction_non_alphanumeric': 0.08625, 'fraction_numerical': 0.00025, 'mean_word_length': 3.5107102593010144, 'pattern_counts': {'":': 0, '<': 27, '<?xml version=': 0, '>': 35, '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': '6206604', 'n_tokens_mistral': 1012, 'n_tokens_neox': 973, 'n_words': 199}