<commit_before>using System;
using System.Collections.Generic;
using System.Reflection;
using System.Security.Permissions;
using ModestTree;

namespace Zenject
{
    // Instantiate given concrete class
    [System.Diagnostics.DebuggerStepThrough]
    public class FactoryUntyped<TContract, TConcrete> : IFactoryUntyped<TContract> where TConcrete : TContract
    {
        [Inject]
        IInstantiator _instantiator;

        // So it can be created without using instantiator
        public IInstantiator Instantiator
        {
            get
            {
                return _instantiator;
            }
            set
            {
                _instantiator = value;
            }
        }

        public virtual TContract Create(params object[] constructorArgs)
        {
            return _instantiator.Instantiate<TConcrete>(constructorArgs);
        }

        public IEnumerable<ZenjectResolveException> Validate(params Type[] extras)
        {
            return _instantiator.Resolver.ValidateObjectGraph<TConcrete>(extras);
        }
    }

    // Instantiate given contract class
    [System.Diagnostics.DebuggerStepThrough]
    public class FactoryUntyped<TContract> : IFactoryUntyped<TContract>
    {
        [Inject]
        IInstantiator _instantiator;

        [InjectOptional]
        Type _concreteType;

        // So it can be created without using container
        public IInstantiator Instantiator
        {
            get
            {
                return _instantiator;
            }
            set
            {
                _instantiator = value;
            }
        }

        public Type ConcreteType
        {
            get
            {
                return _concreteType;
            }
            set
            {
                _concreteType = value;
            }
        }

        [PostInject]
        void Initialize()
        {
            if (_concreteType == null)
            {
                _concreteType = typeof(TContract);
            }

            if (!_concreteType.DerivesFromOrEqual(typeof(TContract)))
            {
                throw new ZenjectResolveException(
                    "Expected type '{0}' to derive from '{1}'".Fmt(_concreteType.Name(), typeof(TContract).Name()));
            }
        }

        public virtual TContract Create(params object[] constructorArgs)
        {
            return (TContract)_instantiator.Instantiate(_concreteType, constructorArgs);
        }

        public IEnumerable<ZenjectResolveException> Validate(params Type[] extras)
        {
            return _instantiator.Resolver.ValidateObjectGraph(_concreteType, extras);
        }
    }
}
<commit_msg>Tweaked FactoryUntyped class to disallow setting Instantiator<commit_after>using System;
using System.Collections.Generic;
using System.Reflection;
using System.Security.Permissions;
using ModestTree;

namespace Zenject
{
    // Instantiate given concrete class
    [System.Diagnostics.DebuggerStepThrough]
    public class FactoryUntyped<TContract, TConcrete> : IFactoryUntyped<TContract> where TConcrete : TContract
    {
        [Inject]
        IInstantiator _instantiator = null;

        // So it can be created without using instantiator
        public IInstantiator Instantiator
        {
            get
            {
                return _instantiator;
            }
        }

        public virtual TContract Create(params object[] constructorArgs)
        {
            return _instantiator.Instantiate<TConcrete>(constructorArgs);
        }

        public IEnumerable<ZenjectResolveException> Validate(params Type[] extras)
        {
            return _instantiator.Resolver.ValidateObjectGraph<TConcrete>(extras);
        }
    }

    // Instantiate given contract class
    [System.Diagnostics.DebuggerStepThrough]
    public class FactoryUntyped<TContract> : IFactoryUntyped<TContract>
    {
        [Inject]
        IInstantiator _instantiator = null;

        [InjectOptional]
        Type _concreteType = null;

        // So it can be created without using container
        public IInstantiator Instantiator
        {
            get
            {
                return _instantiator;
            }
        }

        public Type ConcreteType
        {
            get
            {
                return _concreteType;
            }
        }

        [PostInject]
        void Initialize()
        {
            if (_concreteType == null)
            {
                _concreteType = typeof(TContract);
            }

            if (!_concreteType.DerivesFromOrEqual(typeof(TContract)))
            {
                throw new ZenjectResolveException(
                    "Expected type '{0}' to derive from '{1}'".Fmt(_concreteType.Name(), typeof(TContract).Name()));
            }
        }

        public virtual TContract Create(params object[] constructorArgs)
        {
            return (TContract)_instantiator.Instantiate(_concreteType, constructorArgs);
        }

        public IEnumerable<ZenjectResolveException> Validate(params Type[] extras)
        {
            return _instantiator.Resolver.ValidateObjectGraph(_concreteType, extras);
        }
    }
}

{'fraction_non_alphanumeric': 0.07068567026194145, 'fraction_numerical': 0.0007704160246533128, 'mean_word_length': 1.7755211117049705, 'pattern_counts': {'":': 0, '<': 19, '<?xml version=': 0, '>': 19, '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': '5324180', 'n_tokens_mistral': 1349, 'n_tokens_neox': 1287, 'n_words': 278}