<commit_before>﻿using System;

namespace DTools.Suice
{
    /// <summary>
    /// Dynamic provider is instantiated to create a factory pattern for specific instances who need injectable dependencies.
    /// 
    /// @author DisTurBinG
    /// </summary>
    /// <typeparam name="T"></typeparam>
    internal class DynamicProvider<T> : NoScopeProvider, IProvider<T> where T : class
    {
        public DynamicProvider(Type[] dependencyTypes)
            : base(typeof(T), typeof(T), dependencyTypes)
        {
            
        }

        T IProvider<T>.Provide()
        {
            return (T) base.Provide();
        }

        public override object Provide()
        {
            return this;
        }
    }
}<commit_msg>Dynamic Provider now calls initialize for IInitializables.<commit_after>﻿using System;

namespace DTools.Suice
{
    /// <summary>
    /// Dynamic provider is instantiated to create a factory pattern for specific instances who need injectable dependencies.
    /// 
    /// @author DisTurBinG
    /// </summary>
    /// <typeparam name="T"></typeparam>
    internal class DynamicProvider<T> : NoScopeProvider, IProvider<T> where T : class
    {
        public DynamicProvider(Type[] dependencyTypes)
            : base(typeof(T), typeof(T), dependencyTypes) { }

        T IProvider<T>.Provide()
        {
            T instance = (T) base.Provide();

            if (instance is IInitializable) {
                ((IInitializable)instance).Initialize();
            }

            return instance;
        }

        public override object Provide()
        {
            return this;
        }
    }
}
{'fraction_non_alphanumeric': 0.11063569682151589, 'fraction_numerical': 0.0, 'mean_word_length': 1.9602169981916817, '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': '3295305', 'n_tokens_mistral': 442, 'n_tokens_neox': 423, 'n_words': 116}