<commit_before>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DLaB.Xrm.Plugin;

namespace Example.Plugin
{
    public abstract class PluginBase : IRegisteredEventsPlugin
    {
        private readonly object _handlerLock = new object();
        private PluginHandlerBase _handler;
        private volatile bool _isIntialized;

        private String SecureConfig { get; set; }
        private String UnsecureConfig { get; set; }
        public IEnumerable<RegisteredEvent> RegisteredEvents { get { return ThreadSafeGetOrCreateHandler().RegisteredEvents; } }

        protected PluginBase(string unsecureConfig, string secureConfig)
        {
            UnsecureConfig = unsecureConfig;
            SecureConfig = secureConfig;
        }

        public void Execute(IServiceProvider serviceProvider)
        {
            ThreadSafeGetOrCreateHandler().Execute(serviceProvider);
        }

        private PluginHandlerBase ThreadSafeGetOrCreateHandler()
        {
            if (_handler != null) { return _handler; }

            if (_isIntialized) { return _handler; }

            lock (_handlerLock)
            {
                if (_isIntialized) { return _handler; }

                var local = GetPluginHandler();
                local.SetConfigValues(UnsecureConfig, SecureConfig);
                local.RegisterEvents();
                _handler = local;
                _isIntialized = true;
            }
            return _handler;
        }

        protected abstract PluginHandlerBase GetPluginHandler();
    }
}<commit_msg>Used Interface, rather than plugin base<commit_after>﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using DLaB.Xrm.Plugin;

namespace Example.Plugin
{
    public abstract class PluginBase : IRegisteredEventsPlugin
    {
        private readonly object _handlerLock = new object();
        private PluginHandlerBase _handler;
        private volatile bool _isIntialized;

        private String SecureConfig { get; set; }
        private String UnsecureConfig { get; set; }
        public IEnumerable<RegisteredEvent> RegisteredEvents { get { return ThreadSafeGetOrCreateHandler().RegisteredEvents; } }

        protected PluginBase(string unsecureConfig, string secureConfig)
        {
            UnsecureConfig = unsecureConfig;
            SecureConfig = secureConfig;
        }

        public void Execute(IServiceProvider serviceProvider)
        {
            ThreadSafeGetOrCreateHandler().Execute(serviceProvider);
        }

        private IRegisteredEventsPluginHandler ThreadSafeGetOrCreateHandler()
        {
            if (_handler != null) { return _handler; }

            if (_isIntialized) { return _handler; }

            lock (_handlerLock)
            {
                if (_isIntialized) { return _handler; }

                var local = GetPluginHandler();
                local.SetConfigValues(UnsecureConfig, SecureConfig);
                local.RegisterEvents();
                _handler = local;
                _isIntialized = true;
            }
            return _handler;
        }

        protected abstract PluginHandlerBase GetPluginHandler();
    }
}
{'fraction_non_alphanumeric': 0.06918622371228283, 'fraction_numerical': 0.0, 'mean_word_length': 2.2951807228915664, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '214275', 'n_tokens_mistral': 806, 'n_tokens_neox': 774, 'n_words': 197}