Exemplo n.º 1
0
        private T Build <T>(
            [NotNull] UnitInfo unitInfo,
            [CanBeNull] BuildPlansCollection auxBuildPlans,
            [NotNull] Func <UnitInfo, IEnumerable <object>, BuildPlansCollection, BuildPlansCollection, Builder[], T> build,
            [CanBeNull] Builder[] parentBuilders)
        {
            if (build is null)
            {
                throw new ArgumentNullException(nameof(build));
            }

            return(build(unitInfo, _stages, this, auxBuildPlans, parentBuilders));
        }
Exemplo n.º 2
0
        public BuildSession(
            [NotNull] IEnumerable <object> buildStages,
            [NotNull] BuildPlansCollection buildPlans,
            [CanBeNull] BuildPlansCollection auxBuildPlans,
            [CanBeNull] Builder[] parentBuilders)
        {
            if (buildStages == null)
            {
                throw new ArgumentNullException(nameof(buildStages));
            }
            if (buildPlans == null)
            {
                throw new ArgumentNullException(nameof(buildPlans));
            }

            _buildStages    = buildStages;
            _buildPlans     = buildPlans;
            _auxBuildPlans  = auxBuildPlans;
            _buildSequence  = new List <UnitInfo>(4);
            _parentBuilders = parentBuilders;
        }
Exemplo n.º 3
0
        /// <summary>
        ///   Builds all units represented by <see cref="UnitInfo" />
        /// </summary>
        /// <param name="unitInfo">Building unit "id"</param>
        /// <param name="auxBuildPlans">Additional build plans to build a unit or its dependencies</param>
        /// <returns>Returns an instance or null if null is registered as a unit.</returns>
        /// <exception cref="ArmatureException">Throws if unit wasn't built by this or any parent containers</exception>
        public IReadOnlyList <object> BuildAllUnits(UnitInfo unitInfo, BuildPlansCollection auxBuildPlans = null)
        {
            var buildResult = Build(unitInfo, auxBuildPlans, BuildSession.BuildAllUnits, _parentBuilders);

            return(buildResult.Select(_ => _.Value).ToArray());
        }
Exemplo n.º 4
0
 /// <summary>
 ///   Builds a unit represented by <see cref="UnitInfo" />
 /// </summary>
 /// <param name="unitInfo">Building unit "id"</param>
 /// <param name="auxBuildPlans">Additional build plans to build a unit or its dependencies</param>
 /// <returns>Returns an instance or null if null is registered as a unit.</returns>
 /// <exception cref="ArmatureException">Throws if unit wasn't built by this or any parent containers</exception>
 public BuildResult BuildUnit(UnitInfo unitInfo, BuildPlansCollection auxBuildPlans = null) =>
 Build(unitInfo, auxBuildPlans, BuildSession.BuildUnit, _parentBuilders);
Exemplo n.º 5
0
 /// <summary>
 ///   Builds all Units represented by <paramref name="unitInfo" />
 /// </summary>
 /// <param name="unitInfo">"Id" of the unit to build. See <see cref="IUnitSequenceMatcher" /> for details</param>
 /// <param name="buildStages">The conveyor of build stages. See <see cref="Builder" /> for details</param>
 /// <param name="buildPlans">Build plans used to build a unit</param>
 /// <param name="runtimeBuildPlans">Build plans collection contains additional build plans passed into <see cref="Builder.BuildUnit" /> method </param>
 /// <param name="parentBuilders">
 ///   If unit is not built and <paramref name="parentBuilders" /> are provided, trying to build a unit using
 ///   parent builders one by one in the order they passed into constructor
 /// </param>
 public static IReadOnlyList <BuildResult> BuildAllUnits(
     [NotNull] UnitInfo unitInfo,
     [NotNull] IEnumerable <object> buildStages,
     [NotNull] BuildPlansCollection buildPlans,
     [CanBeNull] BuildPlansCollection runtimeBuildPlans,
     [CanBeNull] Builder[] parentBuilders) => new BuildSession(buildStages, buildPlans, runtimeBuildPlans, parentBuilders).BuildAllUnits(unitInfo);