示例#1
0
        private static IPlanBuilderPolicy GetPlanBuilderFromContext(IBuilderContext context, Type typeToBuild,
                                                                    string idToBuild)
        {
            IPlanBuilderPolicy planBuilder = context.Policies.Get <IPlanBuilderPolicy>(typeToBuild, idToBuild);

            if (planBuilder == null)
            {
                throw new InvalidOperationException("No Plan builder configured");
            }
            return(planBuilder);
        }
示例#2
0
        private static IBuildPlan GetPlanFromContext(IBuilderContext context, Type typeToBuild, string idToBuild)
        {
            IBuildPlanPolicy planPolicy = GetPlanPolicyFromContext(context, typeToBuild, idToBuild);
            IBuildPlan       plan       = planPolicy.Get(typeToBuild);

            if (plan == null)
            {
                IPlanBuilderPolicy builderPolicy = GetPlanBuilderFromContext(context, typeToBuild, idToBuild);
                plan = builderPolicy.CreatePlan(typeToBuild, idToBuild);
                planPolicy.Set(typeToBuild, plan);
            }
            return(plan);
        }