<commit_before>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;

namespace Bogosoft.Data
{
    /// <summary>
    /// An enumerable data reader whose principal operations of connecting to a data source, generating executable
    /// commands and mapping rows in a data reader to objects of a specified type are accomplished by delegates.
    /// </summary>
    /// <typeparam name="TConnection">The type of the database connection.</typeparam>
    /// <typeparam name="TCommand">The type of the database command to be executed.</typeparam>
    /// <typeparam name="TReader">The type of the data reader.</typeparam>
    /// <typeparam name="TEntity">The type of the objects in the sequence.</typeparam>
    public sealed class ComposedDataEnumerable<TConnection, TCommand, TReader, TEntity> : IEnumerable<TEntity>
        where TConnection : DbConnection
        where TCommand : DbCommand
        where TReader : DbDataReader
    {
        Func<TConnection, TCommand> commandProvider;
        Func<TConnection> connector;
        Func<TReader, TEntity> mapper;

        /// <summary>
        /// Create a new instance of the composed data enumerable class.
        /// </summary>
        /// <param name="connector">A delegate responsible for creating a data source connection.</param>
        /// <param name="commandProvider">
        /// A delegate responsible for generating an executable command against a given connection.
        /// </param>
        /// <param name="mapper">A data reader row to entity mapping strategy.</param>
        public ComposedDataEnumerable(
            Func<TConnection> connector,
            Func<TConnection, TCommand> commandProvider,
            Func<TReader, TEntity> mapper
            )
        {
            this.commandProvider = commandProvider;<commit_msg>added null checks for `ComposedDataEnumerable` constructor<commit_after>﻿using System;
using System.Collections;
using System.Collections.Generic;
using System.Data;
using System.Data.Common;

namespace Bogosoft.Data
{
    /// <summary>
    /// An enumerable data reader whose principal operations of connecting to a data source, generating executable
    /// commands and mapping rows in a data reader to objects of a specified type are accomplished by delegates.
    /// </summary>
    /// <typeparam name="TConnection">The type of the database connection.</typeparam>
    /// <typeparam name="TCommand">The type of the database command to be executed.</typeparam>
    /// <typeparam name="TReader">The type of the data reader.</typeparam>
    /// <typeparam name="TEntity">The type of the objects in the sequence.</typeparam>
    public sealed class ComposedDataEnumerable<TConnection, TCommand, TReader, TEntity> : IEnumerable<TEntity>
        where TConnection : DbConnection
        where TCommand : DbCommand
        where TReader : DbDataReader
    {
        Func<TConnection, TCommand> commandProvider;
        Func<TConnection> connector;
        Func<TReader, TEntity> mapper;

        /// <summary>
        /// Create a new instance of the composed data enumerable class.
        /// </summary>
        /// <param name="connector">A delegate responsible for creating a data source connection.</param>
        /// <param name="commandProvider">
        /// A delegate responsible for generating an executable command against a given connection.
        /// </param>
        /// <param name="mapper">A data reader row to entity mapping strategy.</param>
        /// <exception cref="ArgumentNullException">
        /// Thrown in the event that the given connector, command provider or mapping strategy is null.
        /// </exception>
        public ComposedDataEnumerable(
            Func<TConnection> connector,
            Func<TConnection, TCommand> commandProvider,
            Func<TReader, TEntity> mapper
            )
        {
            if (connector is null)
            {
                throw new ArgumentNullException(nameof(connector));
            }

            if (commandProvider is null)
            {
                throw new ArgumentNullException(nameof(commandProvider));
            }

            if (mapper is null)
            {
                throw new ArgumentNullException(nameof(mapper));
            }

            this.commandProvider = commandProvider;
{'fraction_non_alphanumeric': 0.09325714285714286, 'fraction_numerical': 0.0, 'mean_word_length': 2.5577235772357723, 'pattern_counts': {'":': 0, '<': 57, '<?xml version=': 0, '>': 57, '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': '3384954', 'n_tokens_mistral': 1069, 'n_tokens_neox': 1030, 'n_words': 369}