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[] { }));
        }
Beispiel #2
0
        /// <summary>
        /// Adds standard provider node.
        /// </summary>
        /// <typeparam name="TContract">Registration target type.</typeparam>
        /// <param name="nodesBuilder">Nodes builder.</param>
        /// <param name="name">Registration <c>name</c>.</param>
        /// <param name="scopeBinding">Scope binding strategy config (registration, transient, etc.).</param>
        /// <param name="importFilter">Import filter. Controls which registrations of parent node are visible for current node.</param>
        /// <param name="exportToParentFilter">
        /// Export to parent filter. Controls which registrations of <c>this</c> node will be
        /// visible in parent node.
        /// </param>
        /// <param name="exportFilter">Export to children filter. Controls which registrations of <c>this</c> node.</param>
        /// <param name="instanceBuilder">Instance builder config. (Class constructor, existing instance, etc.).</param>
        /// <param name="multiplicity">Multiplicity config. (Singleton, pool, <c>factory</c> etc.).</param>
        /// <param name="disposeHandler">Overrides dispose operation.</param>
        /// <param name="nodes">Action that build nested <c>nodes</c>.</param>
        /// <returns>Fluent syntax continuation.</returns>
        public static IIxBuilder <ICollection <IIxProviderNodeConfig> > Add <TContract>(
            this IIxBuilder <ICollection <IIxProviderNodeConfig> > nodesBuilder,
            string name = null,
            IIxScopeBindingConfig scopeBinding             = null,
            IIxVisibilityFilterConfig importFilter         = null,
            IIxVisibilityFilterConfig exportToParentFilter = null,
            IIxVisibilityFilterConfig exportFilter         = null,
            IIxInstanceBuilderConfig instanceBuilder       = null,
            IIxMultiplicityConfig multiplicity             = null,
            bool autoDisposeEnabled = false,
            IxDisposeHandlerDelegate disposeHandler = null,
            Action <IIxBuilder <ICollection <IIxProviderNodeConfig> > > nodes = null)
        {
            var depNode = new IxStdProviderConfig
            {
                InstanceBuilder      = instanceBuilder,
                Identifier           = new IxIdentifier(typeof(TContract), name),
                ScopeBinding         = scopeBinding,
                Multiplicity         = multiplicity,
                ImportFilter         = importFilter,
                ExportFilter         = exportFilter,
                ExportToParentFilter = exportToParentFilter,
                AutoDisposeEnabled   = autoDisposeEnabled,
                DisposeHandler       = disposeHandler
            };

            nodesBuilder.Config.Add(depNode);

            nodes?.Invoke(
                new IxBuilder <ICollection <IIxProviderNodeConfig> >
            {
                Config = depNode.Nodes
            });

            return(nodesBuilder);
        }
Beispiel #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);
        }