/// <summary>
        /// Query the <see cref="RequirementsContainerParameterValue"/> if it exists or create a new one
        /// </summary>
        /// <param name="reqContainer">The <see cref="RequirementsContainer"/> container</param>
        /// <param name="simpleParameterValue">The queried <see cref="RequirementsContainerParameterValue"/></param>
        /// <returns>A value indicating if the <see cref="RequirementsContainerParameterValue"/> existed</returns>
        protected bool TryQueryOrderParameterOrCreate(RequirementsContainer reqContainer, out RequirementsContainerParameterValue simpleParameterValue)
        {
            var parameterValue = this.QueryOrderParameter(reqContainer);

            if (parameterValue != null)
            {
                simpleParameterValue = parameterValue;
                return(true);
            }

            var iteration = reqContainer.GetContainerOfType <Iteration>();
            Tuple <DomainOfExpertise, Participant> domainTuple;

            if (!this.session.OpenIterations.TryGetValue(iteration, out domainTuple) || domainTuple.Item1 == null)
            {
                throw new InvalidOperationException("The domain is null.");
            }

            simpleParameterValue = new RequirementsContainerParameterValue(Guid.NewGuid(), null, null)
            {
                ParameterType = this.reqOrderParameterType,
                Value         = new ValueArray <string>(new[] { int.MaxValue.ToString() }),
            };

            return(false);
        }
Пример #2
0
        /// <summary>
        /// Create 10-25 <see cref="Thing"/>s from the <see cref="SpecHierarchy"/>
        /// </summary>
        /// <param name="specHierarchy">The <see cref="SpecHierarchy"/></param>
        /// <param name="reqContainer">The <see cref="RequirementsContainer"/> representing the current level of requirement</param>
        private void ComputeRequirementFromSpecHierarchy(SpecHierarchy specHierarchy, RequirementsContainer reqContainer)
        {
            // create a group if the specHierarchy has children
            if (specHierarchy.Children.Any())
            {
                var group = this.CreateRequirementGroup(specHierarchy.Object);
                reqContainer.Group.Add(group);
                foreach (var hierarchy in specHierarchy.Children)
                {
                    this.ComputeRequirementFromSpecHierarchy(hierarchy, group);
                }
            }

            SpecTypeMap specTypeMapping;

            if (!this.typeMap.TryGetValue(specHierarchy.Object.Type, out specTypeMapping))
            {
                // The instance of this type shall not be generated
                return;
            }

            var specObjectTypeMap = (SpecObjectTypeMap)specTypeMapping;

            if (!specObjectTypeMap.IsRequirement)
            {
                var group = this.CreateRequirementGroup(specHierarchy.Object);
                reqContainer.Group.Add(group);
                return;
            }

            var requirement = this.CreateRequirement(specHierarchy.Object);

            if (requirement != null)
            {
                var group = reqContainer as RequirementsGroup;
                if (group != null)
                {
                    requirement.Group = group;
                }

                RequirementsSpecification container = null;
                var specification = reqContainer as RequirementsSpecification;
                container = specification ?? reqContainer.GetContainerOfType <RequirementsSpecification>();

                if (container == null)
                {
                    throw new InvalidOperationException("The RequirementsSpecication container is null.");
                }

                container.Requirement.Add(requirement);
            }
        }