<commit_before>﻿using System;
using JetBrains.Annotations;
using Shience.Publish;

namespace Shience
{
    public static class Shience
    {
        private static IPublisher _publisher;

        public static void SetPublisher([NotNull]IPublisher publisher)
        {
            if (publisher == null)
            {
                throw new ArgumentNullException(nameof(publisher));
            }

            _publisher = publisher;
        }
        
        public static Science New([NotNull]string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            // TODO: test this 
            if (_publisher == null)
            {
                throw new InvalidOperationException("Call Shience.SetPublisher([NotNull]IPublisher publisher) first.");
            }

            return new Science(name, _publisher);
        }
    }
}<commit_msg>#12 adding overloaded factory method to provide IPublisher manually in multi-threading environments<commit_after>﻿using System;
using JetBrains.Annotations;
using Shience.Publish;

namespace Shience
{
    public static class Shience
    {
        private static IPublisher _publisher;

        public static void SetPublisher([NotNull]IPublisher publisher)
        {
            if (publisher == null)
            {
                throw new ArgumentNullException(nameof(publisher));
            }

            _publisher = publisher;
        }
        
        public static Science New([NotNull]string name)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            // TODO: test this 
            if (_publisher == null)
            {
                throw new InvalidOperationException("Call Shience.SetPublisher([NotNull]IPublisher publisher) first.");
            }

            return new Science(name, _publisher);
        }

        public static Science New([NotNull]string name, [NotNull]IPublisher publisher)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                throw new ArgumentNullException(nameof(name));
            }

            if (publisher == null)
            {
                throw new ArgumentNullException(nameof(publisher));
            }

            return new Science(name, publisher);
        }
    }
}
{'fraction_non_alphanumeric': 0.07723911257189811, 'fraction_numerical': 0.0008216926869350862, 'mean_word_length': 1.7237136465324385, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '5769787', 'n_tokens_mistral': 606, 'n_tokens_neox': 577, 'n_words': 143}