예제 #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="IxSingletonProvider"/> class.
        /// </summary>
        /// <param name="host">IndirectX host.</param>
        public IxSingletonProvider(
            IxHost host,
            IxProviderNode parentNode,
            IxStdProviderConfig config,
            IxInstanceFactory instanceFactory,
            IxVisibilityFilter exportFilter,
            IxVisibilityFilter exportToParentFilter,
            IxVisibilityFilter importFilter,
            IxScopeBinderDelegate scopeBinder)
            : base(
                host,
                parentNode,
                config,
                instanceFactory,
                exportFilter,
                exportToParentFilter,
                importFilter,
                scopeBinder,
                config.AutoDisposeEnabled,
                config.DisposeHandler)
        {
            if (parentNode == null)
            {
                throw new ArgumentNullException(nameof(parentNode));
            }

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

            // Adding self provided as default for children.
            VisibleNodes.Add(new IxIdentifier(Identifier.Type), new IxResolvePath(this, new IxProviderNode[] { }));
        }
예제 #2
0
        public IxPerResolveProvider(
            IxHost host,
            [CanBeNull] IxProviderNode parentNode,
            IxProviderNodeConfig config,
            [CanBeNull] IxInstanceFactory instanceFactory,
            IxVisibilityFilter exportFilter,
            IxVisibilityFilter exportToParentFilter,
            IxVisibilityFilter importFilter,
            IxScopeBinderDelegate scopeBinder,
            bool autoDisposeEnabled,
            IxDisposeHandlerDelegate disposeHandler)
            : base(
                host,
                parentNode,
                config,
                instanceFactory,
                exportFilter,
                exportToParentFilter,
                importFilter,
                scopeBinder,
                autoDisposeEnabled,
                disposeHandler)
        {
            VxArgs.NotNull(parentNode, nameof(parentNode));
            VxArgs.NotNull(instanceFactory, nameof(instanceFactory));

            // Adding self provided as default for children.
            VisibleNodes.Add(new IxIdentifier(Identifier.Type), new IxResolvePath(this, new IxProviderNode[] { }));
        }
예제 #3
0
        public IxProviderNode(
            IxHost host,
            [CanBeNull] IxProviderNode parentNode,
            IxProviderNodeConfig config,
            [CanBeNull] IxInstanceFactory instanceFactory,
            IxVisibilityFilter exportFilter,
            IxVisibilityFilter exportToParentFilter,
            IxVisibilityFilter importFilter,
            IxScopeBinderDelegate scopeBinder,
            bool autoDisposeEnabled,
            IxDisposeHandlerDelegate disposeHandler)
        {
            if (host == null)
            {
                throw new ArgumentNullException(nameof(host));
            }

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

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

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

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

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

            _nodes     = new List <IxProviderNode>();
            _nodesById = new Dictionary <IxIdentifier, IxProviderNode>();

            Host       = host;
            ParentNode = parentNode;

            if (config.Identifier == null)
            {
                // ReSharper disable once NotResolvedInText
                throw new ArgumentNullException("config.Identifier");
            }

            Identifier           = (IxIdentifier)config.Identifier;
            InstanceFactory      = instanceFactory;
            ExportFilter         = exportFilter;
            ExportToParentFilter = exportToParentFilter;
            ImportFilter         = importFilter;
            ScopeBinder          = scopeBinder;
            AutoDisposeEnabled   = autoDisposeEnabled;
            DisposeHandler       = disposeHandler;

            ParentNode?.RegisterChild(this);
        }