private bool noInitializedCandidatesError(ComponentRef component, Import import, IEnumerable <ComponentRef> candidatesInProgress)
        {
            var importPoint = component.GetPoint(import);

            string error = "Can't satisfy import";

            if (candidatesInProgress.Any())
            {
                error += ", there are circular dependencies in prerequisity imports";

                foreach (var candidate in candidatesInProgress)
                {
                    makeErrorJoins(importPoint, candidate, "Can't get export because of unsatisfied prerequisities");
                }
            }
            else
            {
                error = noMatchingExportError(importPoint, error);
            }

            //set error to import
            setError(importPoint, error);


            if (import.IsPrerequisity)
            {
                setWarning(component.ExportPoints, "Because of unsatisfied prerequisity import, exports cannot be provided");
            }

            return(false);
        }
        private bool satisfyFromCandidates(ComponentRef component, Import import, IEnumerable <ComponentRef> candidates)
        {
            var importPoint = component.GetPoint(import);

            foreach (var candidate in candidates)
            {
                if (!satisfyPreImports(candidate))
                {
                    setError(importPoint, "Cannot satisfy import, because depending component cannot be instantiated");
                    makeErrorJoins(importPoint, candidate, "This export cannot be provided before prerequisity imports are satisfied");

                    //satisfy all needed requirments
                    return(false);
                }

                if (!satisfyImport(component, import, candidate))
                {
                    //errors were set
                    return(false);
                }
            }

            if (!import.IsPrerequisity)
            {
                // else it will be set via importing constructor
                setImport(importPoint);
            }

            return(true);
        }
        private bool tooManyCandidatesError(ComponentRef component, Import import, IEnumerable <ComponentRef> candidates)
        {
            var importPoint = component.GetPoint(import);

            setError(importPoint, "There are more than one matching component for export satisfiyng");
            foreach (var expProvider in candidates)
            {
                makeErrorJoins(importPoint, expProvider, "Matching export in ambiguous component");
            }
            return(false);
        }
        private void callImportingConstructor(ComponentRef component)
        {
            var args = new List <InstanceRef>();

            foreach (var import in component.Imports)
            {
                if (import.Setter == null) //has to be satisfied via importing constructor
                {
                    var imp = component.GetPoint(import);
                    args.Add(createExport(imp));
                }
            }

            component.Construct(component.ComponentInfo.ImportingConstructor, args.ToArray());
        }
        /// <summary>
        /// find exports which satisfies import from exportsProvider (exportsProvider has been instatiated and its exports has to match into import)
        /// found exports are added into storage
        ///
        /// provide type checking of join, on fail set errors and return false
        /// </summary>
        /// <param name="component"></param>
        /// <param name="import"></param>
        /// <param name="exportsProvider"></param>
        private bool satisfyImport(ComponentRef component, Import import, ComponentRef exportsProvider)
        {
            Debug.Assert(exportsProvider.IsConstructed, "candidate has to be constructed before providing exports");

            var importPoint = component.GetPoint(import);

            foreach (var exportPoint in exportsProvider.ExportPoints)
            {
                if (match(import, exportPoint))
                {
                    var join = new Join(importPoint, exportPoint);
                    _joins.Add(join);

                    if (!typeCheck(join))
                    {
                        return(false);
                    }
                    _storage.Add(importPoint, exportPoint);
                }
            }

            return(true);
        }