Пример #1
0
 /// <summary>
 ///     Adds factor information to the collection.
 /// </summary>
 /// <param name="information"></param>
 /// <returns></returns>
 public FactorEditResult AddFactor(FactorInformation information)
 {
     if (m_factors.ContainsKey(information.FactorName))
     {
         return(FactorEditResult.Exists);
     }
     m_factors.Add(information.FactorName, information);
     return(FactorEditResult.Added);
 }
Пример #2
0
        /// <summary>
        ///     Returns a new object of a cloned type.
        /// </summary>
        /// <returns></returns>
        public FactorCollection Clone()
        {
            var definitions = new FactorCollection();

            foreach (var information in Factors.Values)
            {
                var newInformation = new FactorInformation();
                newInformation.FactorName = information.FactorName;
                newInformation.FactorValues.AddRange(information.FactorValues);

                definitions.AddFactor(newInformation);
            }
            return(definitions);
        }
Пример #3
0
        /// <summary>
        ///     Creates a new factor.
        /// </summary>
        /// <param name="factor">Factor to create.</param>
        /// <returns>A enumerated result detailing if the factor was created or not.</returns>
        public FactorEditResult AddFactor(string factorName)
        {
            // Make sure the factor is in the right format.
            if (string.IsNullOrEmpty(factorName))
            {
                return(FactorEditResult.IncorrectFormat);
            }

            // Make sure the factor does not already exist.
            if (m_factors.ContainsKey(factorName))
            {
                return(FactorEditResult.Exists);
            }

            // Create the new factor.
            var newFactor = new FactorInformation();

            newFactor.FactorName = factorName;
            m_factors.Add(factorName, newFactor);
            return(FactorEditResult.Added);
        }