Skip to content

TinyIoC doesn't allow to override IReactEnvironment with AsPerRequestSingleton lifetime #336

@asmagin

Description

@asmagin

I'm trying to override react components via providing a new implementation of IReactEnvironment.

in order to do that, I've created library "*.React" and added AssemblyRegistration class there.

    public class AssemblyRegistration : IAssemblyRegistration
    {
        /// <summary>
        /// Gets the IoC container. Try to avoid using this and always use constructor injection.
        /// This should only be used at the root level of an object heirarchy.
        /// </summary>
        public static TinyIoCContainer Container
        {
            get { return TinyIoCContainer.Current; }
        }

        /// <summary>
        /// Registers standard components in the React IoC container
        /// </summary>
        /// <param name="container">Container to register components in</param>
        public void Register(TinyIoCContainer container)
        {
            // One instance shared for the whole app
            container.Register<IReactEnvironment, ReduxEnvironment>().AsPerRequestSingleton();
        }
    }

The problem is when I'm running this code I'm getting following error.
image

If I edit this code directly in React.Core or comment out original registration for IReactEnvironment site is working fine.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions